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

fix: 修复分支合并错误

上级 bfa0596d
......@@ -1052,13 +1052,6 @@
"enablePullDownRefresh": false
}
},
{
"path": "pages/API/virtual-payment/virtual-payment-uni-pay",
"style": {
"navigationBarTitleText": "苹果虚拟支付(uni-pay)",
"enablePullDownRefresh": false
}
},
// #endif
// #ifdef APP-IOS
{
......
describe('native-view.uvue', () => {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
it('object', () => {
expect(1).toBe(1)
})
return
}
beforeAll(async () => {
page = await program.reLaunch('/pages/component/native-view/native-view')
});
it('native-view检测init函数是否响应', async () => {
await page.waitFor(600)
const value = await page.data('isLoad')
expect(value).toBe(true)
})
})
<template>
<view>
<native-button class="native-button" style="width: 200px; height: 100px;" :text="buttonText" @buttonTap="ontap"
@load="onload"></native-button>
<time-picker class="native-time-picker" :hour=2 :minute=3 @changed="onChanged"></time-picker>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello',
buttonText: "native-button",
isLoad: false
}
},
onLoad() {
},
methods: {
ontap(e : UniNativeViewEvent) {
uni.showToast({
title: "按钮被点击了"
})
},
onload() {
//标记已初始化 用于自动化测试
this.isLoad = true
},
onChanged(e : UniNativeViewEvent) {
console.log("onchanged-----", e.detail)
}
}
}
</script>
<style>
.native-button {
height: 100px;
width: 100px;
margin: 25px auto 25px auto;
}
.native-time-picker {
margin: 10px auto 25px auto;
border-style: solid;
border-radius: 5px;
}
</style>
{
"id": "uni-native-button",
"displayName": "uni-native-button",
"version": "0.0.1",
"description": "vue开发button原生组件",
"keywords": [
"tencent",
"map",
"tmap"
],
"repository": "",
"engines": {
"HBuilderX": "^4.25"
},
"dcloudext": {
"type": "uts",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "插件不采集任何数据",
"permissions": "无"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"Vue": {
"vue2": "n",
"vue3": "y"
},
"App": {
"app-android": {
"minVersion": "21"
},
"app-ios": {
"minVersion": "9"
}
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "u",
"QQ": "y",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}
## native-button
通过 object 封装原生平台Button按钮
import { Button } from "android.widget"
export class NativeButton {
$element: UniNativeViewElement;
constructor(element: UniNativeViewElement) {
this.$element = element;
this.bindView();
}
button: Button | null = null;
bindView() {
//通过UniElement.getAndroidActivity()获取android平台activity 用于创建view的上下文
this.button = new Button(this.$element.getAndroidActivity()!); //构建原生view
//限制原生Button 文案描述不自动大写
this.button?.setAllCaps(false)
//监听原生Button点击事件
this.button?.setOnClickListener(_ => {
const detail = {}
//构建自定义UniNativeViewEvent返回对象
const event = new UniNativeViewEvent("customClick", detail)
//响应分发原生Button的点击事件
this.$element.dispatchEvent(event)
})
//UniNativeViewEvent 绑定 安卓原生view
this.$element.bindAndroidView(this.button!);
}
updateText(text: string) {
//更新原生Button 文案描述
this.button?.setText(text)
}
destroy() {
//数据回收
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册