refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范
这个提交包含在:
@@ -0,0 +1,56 @@
|
||||
<template>
|
||||
<!--建议只存在一个根节点,如果native-view存在兄弟节点则需要将其包裹处理-->
|
||||
<view>
|
||||
<native-view style="height: 100px;" @init="onviewinit" @customClick="ontap"></native-view>
|
||||
<button style="width: 50%;margin: 10px 0px;align-self: center;">测试按钮</button>
|
||||
</view>
|
||||
</template>
|
||||
<script setup lang="uts">
|
||||
import { NativeButton } from "@/uni_modules/native-button";
|
||||
let button : NativeButton | null = null
|
||||
|
||||
//声明属性
|
||||
const props = defineProps<{ text : string }>()
|
||||
|
||||
//声明事件
|
||||
const emit = defineEmits<{
|
||||
(e : "load") : void
|
||||
(e : "buttonTap", event : UniNativeViewEvent) : void
|
||||
}>()
|
||||
|
||||
//声明方法
|
||||
function updateText(value : string) {
|
||||
button?.updateText(value)
|
||||
}
|
||||
|
||||
//监听属性变化
|
||||
watchEffect(() => {
|
||||
const text = props.text
|
||||
updateText(text)
|
||||
})
|
||||
|
||||
/**
|
||||
* native-view组件初始化时触发
|
||||
* 用于绑定App平台原生View
|
||||
*/
|
||||
function onviewinit(e : UniNativeViewInitEvent) {
|
||||
//获取UniNativeViewElement 传递给NativeButton对象
|
||||
button = new NativeButton(e.detail.element);
|
||||
updateText(props.text)
|
||||
emit("load")
|
||||
}
|
||||
|
||||
/**
|
||||
* 将native-view组件的ontap事件转换为buttonTap事件
|
||||
*/
|
||||
function ontap(e : UniNativeViewEvent) {
|
||||
emit("buttonTap", e)
|
||||
}
|
||||
|
||||
/**
|
||||
* App平台需要主动释放资源
|
||||
*/
|
||||
onUnmounted(() => {
|
||||
button?.destroy()
|
||||
})
|
||||
</script>
|
||||
在新工单中引用
屏蔽一个用户