控制器

    return $this->render('test',[
         'jssdk' => $this->_app->jssdk
    ]);

视图

<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
    //数组内为jssdk授权可用的方法,按需添加,详细查看微信jssdk的方法
    wx.config(<?php echo $jssdk->buildConfig(array('onMenuShareQQ', 'onMenuShareWeibo'), true) ?>);
</script>

结果如下:

<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
wx.config({
    debug: true,
    appId: 'wx3cf0f39249eb0e60',
    timestamp: 1430009304,
    nonceStr: 'qey94m021ik',
    signature: '4F76593A4245644FAE4E1BC940F6422A0C3EC03E',
    jsApiList: ['onMenuShareQQ', 'onMenuShareWeibo']
});
</script>

上次更新:2018-01-18