当前位置: 首页 > news >正文

赣州市建设考勤网站动漫设计与制作专业学校

赣州市建设考勤网站,动漫设计与制作专业学校,如何开发微信小程序,wordpress 新建表单uniapp因为要兼容小程序等,会重写wx对象,导致引入的jweixin-1.6.0.js中对象不生效。 综合网络资料,有两种解决方案: 一,通过npm工具引入 npm install jweixin-module --save 实际上是借用了wx的另一个对象jWeixin …

uniapp因为要兼容小程序等,会重写wx对象,导致引入的jweixin-1.6.0.js中对象不生效。

综合网络资料,有两种解决方案:

一,通过npm工具引入

npm install jweixin-module --save

 实际上是借用了wx的另一个对象jWeixin

//main.jsimport jWeixin from 'jweixin-module'
Vue.prototype.$wx = jWeixin
// index.jsthis.$wx.config({debug: true,appId,timestamp,nonceStr,signature,jsApiList,
})
this.$wx.ready(()=> {})

 参考文章:uniapp开发h5 调用微信sdk 全网最全指南!!!! 血泪史!!!

二,手动引入

鉴于uniapp会重写wx的特性,在初始化后,可以再手动引入js,覆盖原有的wx对象

// 新增模板 template.html 
<!DOCTYPE html>
<html lang="zh-CN"><head><meta charset="utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><title><%= htmlWebpackPlugin.options.title %></title><!-- Open Graph data --><!-- <meta property="og:title" content="Title Here" /> --><!-- <meta property="og:url" content="http://www.example.com/" /> --><!-- <meta property="og:image" content="http://example.com/image.jpg" /> --><!-- <meta property="og:description" content="Description Here" /> --><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +(coverSupport ? ', viewport-fit=cover' : '') +'" />')</script><link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" /></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id="app"></div><!-- built files will be auto injected --></body><!-- <script>window.wx = {}</script><script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> -->
</html>
// manifest.json
"h5" : {"optimization" : {"treeShaking" : {"enable" : true}},"sdkConfigs" : {"maps" : {}},"router" : {// "base" : "/process-client/","mode" : "history"},"devServer" : {"disableHostCheck" : true,"proxy" : {"/api" : {"target" : "http://xxx.xx.xxx.xxx:xxx","changeOrigin" : true,"secure" : false,"logLevel" : "debug","pathRewrite" : {"^/api" : ""}}},"https" : false},"template" : "template.html"}
// utils/wx-sdk.jsexport const createdScript = (callback) => {window.wx = nullconst script1 = document.createElement('script')script1.setAttribute('type', 'text/javascript')script1.setAttribute('src', 'https://res.wx.qq.com/open/js/jweixin-1.2.0.js')document.head.appendChild(script1)script1.onload = function () {window.wx = window.jWeixincallback && callback()}
}
// App.vue<script>
import { createdScript } from '@/utils/wx-sdk.js'
export default {onShow: function () {console.log('App Show')createdScript(() => {api({url: window.location.href}).then(([err, res]) => {if (err) {return}wx.config({debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。appId: res.appId, // 必填,企业微信的corpIDtimestamp: Number(res.timestamp), // 必填,生成签名的时间戳nonceStr: res.nonceStr, // 必填,生成签名的随机串signature: res.signature, // 必填,签名,见 附录-JS-SDK使用权限签名算法jsApiList: []})})})},
}
</script>

http://www.yayakq.cn/news/202153/

相关文章:

  • 成都网站网络建设四网合一的网站
  • 网站优化公司哪家好外贸seo培训
  • 辽宁建设工程信息网官网新网站是哪个厦门建设企业网站
  • 金昌网站建设多久可以拿证
  • 泸县城乡住房建设厅网站冒用他人公司做网站
  • 深圳推广公司哪家最好广州seo公司排行
  • 课程网站开发运行环境跨境电商公司排名
  • 做网站打广告凡科建站网站建设
  • ps做分享类网站效果图精准扶贫网站建设的意义
  • 保定网站建设方案推广个人网站备案资料
  • 怎么查看网站死链接哪家做网站的
  • 青岛开发区网站建设苏州营销网站建设公司
  • 怎么把网站制作成app中国建筑劳务分包平台
  • 淄博企业网站建设哪家好天津南洋建设集团网站
  • 三大框架对网站开发的作用教育类网站首页设计模板
  • 做网站软件的大连seo顾问
  • 做网站卖资料象客企业网站做优化排名
  • 网站建设与管理实践实践报告网站建设谈单情景对话
  • 网站制作需要什么资料作文大全网站链接
  • 18款禁用软件app网站入口平面设计网上接单一个月能赚多少
  • 政务网站建设管理的论文动态ppt模板下载免费完整版
  • dedecms能制作几个网站wordpress footer 插件
  • 做后台网站天津公司网站设计
  • 如何做花店网站全景网站开发
  • 萝岗公司网站建设电子商务网站特点
  • 景区协会官方网站建设泉州建设人才网站
  • 建网页还是网站好江苏省建设厅副厅长网站
  • 做网站可以参考的网站哈尔滨网站seo
  • 贵州城乡住房建设部网站深圳宝安区房价多少钱一平方
  • vs做网站加背景郑州seo顾问培训