提交 067fee4a 编写于 作者: shutao-dc's avatar shutao-dc

uni-native-button rename native-button uni-time-picker rename native-time-picker

上级 395fc4f1
<template> <template>
<native-view @init="onviewinit" @customClick="ontap"></native-view>
<native-view @init="onviewinit" @customClick="onclick"></native-view>
</template> </template>
<script lang="uts"> <script lang="uts">
import { NativeButton } from "@/uni_modules/native-button";
import { NativeButton } from "@/uni_modules/uni-native-button";
export default { export default {
data() { data() {
return { return {
button: null as NativeButton | null, button: null as NativeButton | null,
value : "" value: ""
} }
}, },
props: { props: {
...@@ -27,30 +20,28 @@ ...@@ -27,30 +20,28 @@
"text": { "text": {
handler(newValue : string, oldValue : string) { handler(newValue : string, oldValue : string) {
this.value = newValue this.value = newValue
this.button?.updateText(this.value) this.updateText(newValue)
}, },
immediate: true immediate: true
}, },
}, },
methods: { methods: {
//native-view初始化时触发此方法
onviewinit(e : UniNativeViewInitEvent) { onviewinit(e : UniNativeViewInitEvent) {
//获取UniNativeViewElement 传递给NativeButton插件
this.button = new NativeButton(e.detail.element); this.button = new NativeButton(e.detail.element);
this.button?.updateText(this.value) this.button?.updateText(this.value)
this.$emit("load")
}, },
onclick(e: UniNativeViewEvent) { ontap(e: UniNativeViewEvent) {
this.$emit("buttonTap", e) this.$emit("buttonTap", e)
},
updateText(value: string) {
this.button?.updateText(value)
} }
}, },
unmounted() { unmounted() {
// #ifdef APP-IOS
// iOS平台需要主动释放 uts 实例 // iOS平台需要主动释放 uts 实例
this.button.destroy() this.button?.destroy()
// #endif
} }
} }
</script> </script>
<style>
</style>
...@@ -23,7 +23,7 @@ export class NativeButton { ...@@ -23,7 +23,7 @@ export class NativeButton {
this.$element.dispatchEvent(event) this.$element.dispatchEvent(event)
}) })
//UniNativeViewEvent 绑定 安卓原生view //UniNativeViewEvent 绑定 安卓原生view
this.$element.bindAndroidView(button!); this.$element.bindAndroidView(this.button!);
} }
updateText(text: string) { updateText(text: string) {
...@@ -31,4 +31,7 @@ export class NativeButton { ...@@ -31,4 +31,7 @@ export class NativeButton {
this.button?.setText(text) this.button?.setText(text)
} }
destroy(){
//数据回收
}
} }
<template> <template>
<native-view class="def-picker" @init="onviewinit" @timechanged="ontimechanged"></native-view> <view class="def-picker">
<native-view style="width: 100%; height: 100%;" @init="onviewinit" @timechanged="ontimechanged"></native-view>
</view>
</template> </template>
<script lang="uts"> <script lang="uts">
import { NativeTimePicker } from "@/uni_modules/uni-time-picker"; import { NativeTimePicker } from "@/uni_modules/native-time-picker";
export default { export default {
......
import { TimePicker } from "android.widget" import TimePicker from "android.widget.TimePicker"
export class NativeTimePicker { export class NativeTimePicker {
$element : UniNativeViewElement; $element : UniNativeViewElement;
...@@ -28,5 +28,4 @@ export class NativeTimePicker { ...@@ -28,5 +28,4 @@ export class NativeTimePicker {
setMinute(minute: number) { setMinute(minute: number) {
this.picker?.setMinute(minute.toInt()) this.picker?.setMinute(minute.toInt())
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册