真機無法顯示wx-open-launch-weapp標(biāo)簽的 ,請先完成簽名校驗,校驗完成 后,標(biāo)簽才會顯示!
真機無法顯示wx-open-launch-weapp標(biāo)簽的 ,請先完成簽名校驗,校驗完成 后,標(biāo)簽才會顯示!
真機無法顯示wx-open-launch-weapp標(biāo)簽的 ,請先完成簽名校驗,校驗完成 后,標(biāo)簽才會顯示!
// 跳轉(zhuǎn)小程序需要將相關(guān)參數(shù)傳入 所以需要動態(tài)設(shè)置
// 先看view部分
<view class="bottom text-white">
<view v-html="wxOpenTags" style="width:100%;height:50px;">
</view>
</view>
// 這是利用vue的v-html指令來做解析html
that.wxOpenTags =`<wx-open-launch-weapp path="pages/start/start.html?userAccount=${userAccount.mobilePhone}&psd=${userAccount.password}"
id="launch-wxapp"username="gh_8f2a2b49cab1" @error="handleErrorFn" @launch="handleLaunchFn">
<template>
<style>.box{display:flex;justify-content:center;align-items:center} .btn {width:100px; height: 50px;background-color: #1c92d2;
color:#ffffff}
</style>
<div class="box">
<button class="btn">一鍵進入【小程序】</button>
</div>
</template>
</wx-open-launch-weapp>`
// 開始是想寬度不能寫死 要適應(yīng)屏幕寬度,結(jié)果寫100% 并沒有效果。
然后又外層的父元素設(shè)置100%,同樣是無效啊,心累,
每一次測試都需要在打包h5 然后部署到服務(wù)端,然后通過手機來測試,
原因是uniapp依賴node_modules 在小程序無法運行,然后微信開發(fā)者工具也沒法調(diào)試 簽名校驗問題
,唯一的辦法就是 部署然后手機測試
// 重點 通過獲取外層元素的寬度來 動態(tài)設(shè)置btn的寬度
showXiaochengxu() {
let that = this;
let userJson = uni.getStorageSync('userAccount') || "";
if (!userJson) return console.log("userJson", userJson);;
let userAccount = JSON.parse(userJson)
that.isShow = true;
let info = uni.createSelectorQuery().select(".bottom");
info.boundingClientRect(function(data) { //data - 各種參數(shù)
console.log(data.width) // 獲取元素寬度
that.wxOpenTags =
`<wx-open-launch-weapp
path="pages/start/start.html?userAccount=${userAccount.mobilePhone}&psd=${userAccount.password}"
id="launch-wxapp"
username="gh_8f2a2b49cab1" @error="handleErrorFn" @launch="handleLaunchFn">
<template>
<style>.box{display:flex;justify-content:center;align-items:center} .btn {width:${data.width}px; height: 50px;background-color: #1c92d2;color:#ffffff}</style>
<div class="box">
<button class="btn">一鍵進入【小程序】</button>
</div>
</template>
</wx-open-launch-weapp>`
}).exec()
}