組件在mounted生命周期觸發(fā)判斷是否需要彈出,組件內(nèi)容如有需求可自行修改。
使用方法:
1、在 manifest.json 源碼視圖文件中 找到并添加以下內(nèi)容
"mp-weixin" : {
........
"__usePrivacyCheck__" : true
},
2、將壓縮包文件放至自己程序代碼目錄下,例如 :/項目根目錄/components/ 下
- 如果使用位置較多,可以使用全局注冊
// 在main.js 中 添加如下代碼
import PrivacyPopup from '@/components/privacyPopup/index.vue';
Vue.component('PrivacyPopup',PrivacyPopup);
注意:注冊全局組件必須要引入Vue之后。
// 在需要使用的文件中添加以下代碼
<template>
<view>
<!-- #ifdef MP-WEIXIN -->
<!-- 顯示在底部 -->
<!-- <privacy-popup ref="privacyComponent" position="bottom" ></privacy-popup> -->
<!-- 顯示在中間 -->
<privacy-popup ref="privacyComponent"></privacy-popup>
<!-- #endif -->
</view>
</template>
- 如果是少數(shù)文件使用,直接在需要添加的文件中引入使用
<template>
<view>
<!-- #ifdef MP-WEIXIN -->
<!-- 顯示在底部 -->
<!-- <privacy-popup ref="privacyComponent" position="bottom" ></privacy-popup> -->
<!-- 顯示在中間 -->
<privacy-popup ref="privacyComponent"></privacy-popup>
<!-- #endif -->
</view>
</template>
<script>
import PrivacyPopup from '@/components/privacyPopup/index.vue';
export default {
components: {
PrivacyPopup
},
}
</script>