Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
6315018c
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
6315018c
编写于
8月 12, 2024
作者:
shutao-dc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增native-view示例
上级
7ff5fb51
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
73 addition
and
17 deletion
+73
-17
pages.json
pages.json
+9
-1
pages/component/native-view/native-view.uvue
pages/component/native-view/native-view.uvue
+48
-0
uni_modules/uni-native-button/components/native-button/native-button.uvue
...native-button/components/native-button/native-button.uvue
+3
-3
uni_modules/uni-native-button/utssdk/app-android/index.uts
uni_modules/uni-native-button/utssdk/app-android/index.uts
+5
-5
uni_modules/uni-time-picker/components/time-picker/time-picker.uvue
...s/uni-time-picker/components/time-picker/time-picker.uvue
+3
-3
uni_modules/uni-time-picker/utssdk/app-android/index.uts
uni_modules/uni-time-picker/utssdk/app-android/index.uts
+5
-5
未找到文件。
pages.json
浏览文件 @
6315018c
...
...
@@ -483,6 +483,14 @@
"navigationBarTitleText"
:
"涂鸦"
}
},
//
#ifndef
WEB
{
"path"
:
"pages/component/native-view/native-view"
,
"style"
:
{
"navigationBarTitleText"
:
"native-view"
}
},
//
#endif
{
"path"
:
"pages/tabBar/API"
,
"style"
:
{
...
...
@@ -2751,4 +2759,4 @@
]
}
]
}
\ No newline at end of file
}
pages/component/native-view/native-view.uvue
0 → 100644
浏览文件 @
6315018c
<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;
}
</style>
uni_modules/uni-native-button/components/native-button/native-button.uvue
浏览文件 @
6315018c
<template>
<
object @init="onObjectInit" @customClick="onclick"></object
>
<
native-view @init="onviewinit" @customClick="onclick"></native-view
>
</template>
...
...
@@ -33,12 +33,12 @@
},
},
methods: {
on
ObjectInit(e : UniObject
InitEvent) {
on
viewinit(e : UniNativeView
InitEvent) {
this.button = new NativeButton(e.detail.element);
this.button?.updateText(this.value)
this.$emit("load")
},
onclick(e: Uni
ObjectCustom
Event) {
onclick(e: Uni
NativeView
Event) {
this.$emit("buttonTap", e)
}
},
...
...
uni_modules/uni-native-button/utssdk/app-android/index.uts
浏览文件 @
6315018c
import { Button } from "android.widget"
export class NativeButton {
$element : Uni
Object
Element;
$element : Uni
NativeView
Element;
constructor(element : Uni
Object
Element) {
constructor(element : Uni
NativeView
Element) {
this.$element = element;
bindView();
}
...
...
@@ -17,12 +17,12 @@ export class NativeButton {
//监听原生Button点击事件
this.button?.setOnClickListener(_ => {
const detail = {}
//构建自定义Uni
ObjectCustom
Event返回对象
const event = new Uni
ObjectCustom
Event("customClick", detail)
//构建自定义Uni
NativeView
Event返回对象
const event = new Uni
NativeView
Event("customClick", detail)
//响应分发原生Button的点击事件
$element.dispatchEvent(event)
})
//Uni
ObjectElem
ent 绑定 安卓原生view
//Uni
NativeViewEv
ent 绑定 安卓原生view
$element.bindAndroidView(button!);
}
...
...
uni_modules/uni-time-picker/components/time-picker/time-picker.uvue
浏览文件 @
6315018c
<template>
<
object class="def-picker" @init="onObjectInit" @timechanged="onTimeChanged"></object
>
<
native-view class="def-picker" @init="onviewinit" @timechanged="ontimechanged"></native-view
>
</template>
<script lang="uts">
...
...
@@ -47,11 +47,11 @@
},
},
methods: {
on
ObjectInit(e : UniObject
InitEvent) {
on
viewinit(e : UniNativeView
InitEvent) {
this.picker = new NativeTimePicker(e.detail.element, this.hourValue, this.minuteValue);
this.$emit("load")
},
on
TimeChanged(e : UniObjectCustom
Event) {
on
timechanged(e : UniNativeView
Event) {
this.$emit("changed", e)
}
},
...
...
uni_modules/uni-time-picker/utssdk/app-android/index.uts
浏览文件 @
6315018c
...
...
@@ -2,9 +2,9 @@ import { TimePicker } from "android.widget"
import { View } from "android.view"
export class NativeTimePicker {
$element : Uni
Object
Element;
$element : Uni
NativeView
Element;
constructor(element : Uni
Object
Element, hour: number, minute: number) {
constructor(element : Uni
NativeView
Element, hour: number, minute: number) {
this.$element = element;
bindView(hour, minute);
}
...
...
@@ -17,7 +17,7 @@ export class NativeTimePicker {
setMinute(minute)
this.picker?.setOnTimeChangedListener((_, hourOfDay, minute) => {
const detail = {"hour": hourOfDay, "minute": minute}
const event = new Uni
ObjectCustom
Event("timechanged", detail)
const event = new Uni
NativeView
Event("timechanged", detail)
$element.dispatchEvent(event)
})
}
...
...
@@ -25,9 +25,9 @@ export class NativeTimePicker {
setHour(hour: number) {
this.picker?.setHour(hour.toInt())
}
setMinute(minute: number) {
this.picker?.setMinute(minute.toInt())
}
}
\ No newline at end of file
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录