提交 75a27954 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

Merge branch 'dev' of gitcode.net:dcloud/hello-uni-app-x into dev

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