提交 f9d00337 编写于 作者: zhaofengliang920817's avatar zhaofengliang920817

调整 open-type 示例。

上级 8fe93144
...@@ -205,14 +205,14 @@ ...@@ -205,14 +205,14 @@
"navigationBarTitleText": "textarea | 多行输入框" "navigationBarTitleText": "textarea | 多行输入框"
} }
}, },
// #ifdef APP // // #ifdef APP
{ // {
"path": "pages/component/open-type/open-type", // "path": "pages/component/open-type/open-type",
"group": "0,3,12", // "group": "0,3,12",
"style": { // "style": {
"navigationBarTitleText": "button | open-type" // "navigationBarTitleText": "button | open-type"
} // }
}, // },
//#endif //#endif
{ {
"path": "pages/component/slider/slider", "path": "pages/component/slider/slider",
......
<template> <template>
<!-- #ifdef APP --> <!-- #ifdef APP -->
<scroll-view style="flex:1"> <scroll-view style="flex:1">
<!-- #endif --> <!-- #endif -->
<button id="opentype" style="margin: 12px;" type="primary" <button id="opentype" style="margin: 12px;" type="primary"
open-type="agreePrivacyAuthorization">agreePrivacyAuthorization</button> open-type="agreePrivacyAuthorization">agreePrivacyAuthorization</button>
<!-- #ifdef APP -->
</scroll-view> <button style="margin: 12px;" type="warn" @click="reset">resetPrivacyAuthorization</button>
<!-- #endif -->
</template>
<script> <text style="margin: 12px; color:red; font-size: 18px;">当前隐私政策状态:{{ state }}</text>
export default { <text style="margin: 12px; color:darkred; font-size: 16px;">true = 已同意隐私协议; false = 未同意隐私协议</text>
data() { <!-- #ifdef APP -->
return { </scroll-view>
isAgreeRes: false, <!-- #endif -->
log: "", </template>
number: 0
} <script>
}, export default {
unmounted() { data() {
console.log('unmounted', this.number) return {
uni.offPrivacyAuthorizationChange(this.number) isAgreeRes: false,
}, log: "",
onLoad() { number: 0,
this.number = uni.onPrivacyAuthorizationChange((callback) => { state: false
}
},
unmounted() {
console.log('unmounted', this.number)
uni.offPrivacyAuthorizationChange(this.number)
},
onLoad() {
uni.getPrivacySetting({
success: (res) => {
this.state = !res.needAuthorization
}
})
this.number = uni.onPrivacyAuthorizationChange((callback) => {
this.isAgreeRes = !callback.needAuthorization this.isAgreeRes = !callback.needAuthorization
uni.showToast({ this.state = this.isAgreeRes
title: 'isPrivacyAgree:' + this.isAgreeRes uni.showToast({
}) title: 'isPrivacyAgree:' + this.isAgreeRes
}) })
}, })
methods: { },
} methods: {
} reset() {
</script> uni.resetPrivacyAuthorization()
}
<style> }
}
</script>
<style>
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册