看效果
wxcomponents 下放的是微信小程序原生代碼寫的組件。我進(jìn)行了封裝
上干貨
在你下uniApp 項(xiàng)目的根目錄創(chuàng)建一個(gè) wxcomponents 名字千萬不要錯(cuò) 京東、支付寶燈參考下面圖片 官方文檔也有介紹
然后在你需要引入原生功能的頁面里面引入你的組件(我這里提前已經(jīng)放過來了。在上面圖可看到) 然后打開 pages.json 找到你的頁面文章來源:http://www.zghlxwxcb.cn/news/detail-757502.html
{
// 如果您是通過uni_modules形式引入uView,可以忽略此配置
"easycom": {
"^u-(.*)": "@/uni_modules/uview-ui/components/u-$1/u-$1.vue"
},
"pages": [ //pages數(shù)組中第一項(xiàng)表示應(yīng)用啟動(dòng)頁,參考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "首頁",
"usingComponents": { //調(diào)用的微信原生寫的功能
"wxprint": "/wxcomponents/print/index/index"
}
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
},
"uniIdRouter": {}
}
然后再你的頁面 使用上面注冊(cè)的組件 就可以了文章來源地址http://www.zghlxwxcb.cn/news/detail-757502.html
<view class="u-page">
<wxprint />
</view>
到了這里,關(guān)于UniApp項(xiàng)目中 使用微信小程序原生語言 進(jìn)行開發(fā)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!