web-view 組件是一個可以用來承載網頁的容器,會自動鋪滿整個小程序頁面。個人類型與海外類型的小程序暫不支持使用。
開發環境:angular + 微信小程序

<!-- wxml --> <!-- 指向微信公眾平台首頁的web-view -->
<web-view src="http://localhost:4200/"></web-view>
在Angular中調用微信小程序JSSDK
index.html
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Wechath5</title> <base href="/"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/x-icon" href="favicon.ico"> <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script> </head> <body> <app-root></app-root> </body> </html>
在Angular組件中調用小程序JSSDK提供方法接口
import { Component, OnInit } from '@angular/core';
declare var wx: any;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
info = null;
ngOnInit() {
const that = this;
// 微信接口
wx.miniProgram.getEnv(function (res) {
that.info = res.miniprogram;
});
}
}
小程序向H5傳遞參數的方式 url?id=1
H5返回小程序並傳遞參數
wx.miniProgram.redirectTo({ url: '../index/index?name=word' });
