Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
de164aed
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6005
Star
91
Fork
164
代码
文件
提交
分支
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看板
提交
de164aed
编写于
7月 23, 2024
作者:
shutao-dc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增object示例
上级
c0a48236
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
246 addition
and
1 deletion
+246
-1
pages.json
pages.json
+9
-1
pages/component/object/object.test.js
pages/component/object/object.test.js
+18
-0
pages/component/object/object.uvue
pages/component/object/object.uvue
+39
-0
uni_modules/uni-native-button/changelog.md
uni_modules/uni-native-button/changelog.md
+0
-0
uni_modules/uni-native-button/components/native-button/native-button.vue
...-native-button/components/native-button/native-button.vue
+53
-0
uni_modules/uni-native-button/package.json
uni_modules/uni-native-button/package.json
+87
-0
uni_modules/uni-native-button/readme.md
uni_modules/uni-native-button/readme.md
+3
-0
uni_modules/uni-native-button/utssdk/app-android/config.json
uni_modules/uni-native-button/utssdk/app-android/config.json
+3
-0
uni_modules/uni-native-button/utssdk/app-android/index.uts
uni_modules/uni-native-button/utssdk/app-android/index.uts
+34
-0
未找到文件。
pages.json
浏览文件 @
de164aed
...
@@ -1751,7 +1751,15 @@
...
@@ -1751,7 +1751,15 @@
"navigationBarTitleText"
:
""
,
"navigationBarTitleText"
:
""
,
"backgroundColorContent"
:
"#fffae8"
"backgroundColorContent"
:
"#fffae8"
}
}
}
},
//
#ifdef
APP-ANDROID
{
"path"
:
"pages/component/object/object"
,
"style"
:
{
"navigationBarTitleText"
:
"自定义组件"
}
}
//
#endif
],
],
"globalStyle"
:
{
"globalStyle"
:
{
"pageOrientation"
:
"portrait"
,
"pageOrientation"
:
"portrait"
,
...
...
pages/component/object/object.test.js
0 → 100644
浏览文件 @
de164aed
describe
(
'
object.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/object/object
'
)
await
page
.
waitFor
(
'
native-button
'
);
});
it
(
'
object检测init函数是否相应
'
,
async
()
=>
{
await
page
.
waitFor
(
600
)
const
value
=
await
page
.
data
(
'
isLoad
'
)
expect
(
value
).
toBe
(
true
)
})
})
pages/component/object/object.uvue
0 → 100644
浏览文件 @
de164aed
<template>
<view>
<native-button class="native-button" style="width: 200px; height: 100px;" :text="buttonText" @tap="ontap" @load="onload"></native-button>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello',
buttonText: "封装object实现的button",
isLoad: false
}
},
onLoad() {
},
methods: {
ontap(e: UniObjectCustomEvent) {
console.log("native-button----------"+e.type)
},
onload() {
//标记已初始化 用于自动化测试
this.isLoad = true
}
}
}
</script>
<style>
.native-button {
height: 100px;
width: 100px;
margin: 100px auto 25px auto;
}
</style>
uni_modules/uni-native-button/changelog.md
0 → 100644
浏览文件 @
de164aed
uni_modules/uni-native-button/components/native-button/native-button.vue
0 → 100644
浏览文件 @
de164aed
<
template
>
<object
@
init=
"onObjectInit"
@
click=
"onclick"
></object>
</
template
>
<
script
lang=
"uts"
>
import
{
NativeButton
}
from
"
@/uni_modules/uni-native-button
"
;
export
default
{
data
()
{
return
{
button
:
null
as
NativeButton
|
null
,
value
:
""
}
},
props
:
{
"
text
"
:
{
type
:
String
,
default
:
''
}
},
watch
:
{
"
text
"
:
{
handler
(
newValue
:
string
,
oldValue
:
string
)
{
this
.
value
=
newValue
this
.
button
?.
updateText
(
this
.
value
)
},
immediate
:
true
},
},
methods
:
{
onObjectInit
(
e
:
UniObjectInitEvent
)
{
this
.
button
=
new
NativeButton
(
e
.
detail
.
element
);
this
.
button
?.
updateText
(
this
.
value
)
this
.
$emit
(
"
init
"
)
},
onclick
(
e
:
UniObjectCustomEvent
)
{
this
.
$emit
(
"
tap
"
,
e
)
}
},
unmounted
()
{
}
}
</
script
>
<
style
>
</
style
>
uni_modules/uni-native-button/package.json
0 → 100644
浏览文件 @
de164aed
{
"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"
}
}
}
}
}
uni_modules/uni-native-button/readme.md
0 → 100644
浏览文件 @
de164aed
## native-button
通过 object 分装原生平台Button按钮
uni_modules/uni-native-button/utssdk/app-android/config.json
0 → 100644
浏览文件 @
de164aed
{
"minSdkVersion"
:
"21"
}
\ No newline at end of file
uni_modules/uni-native-button/utssdk/app-android/index.uts
0 → 100644
浏览文件 @
de164aed
import { Button } from "android.widget"
export class NativeButton {
$element : UniObjectElement;
constructor(element : UniObjectElement) {
this.$element = element;
bindView();
}
button : Button | null = null;
bindView() {
//通过UniElement.getAndroidActivity()获取android平台activity 用于创建view的上下文
this.button = new Button($element.getAndroidActivity()!); //构建原生view
//限制原生Button 文案描述不自动大写
this.button?.setAllCaps(false)
//监听原生Button点击事件
this.button?.setOnClickListener(_ => {
const detail = {}
//构建自定义UniObjectCustomEvent返回对象
const event = new UniObjectCustomEvent("click", detail)
//响应分发原生Button的点击事件
$element.dispatchEvent(event)
})
//UniObjectElement 绑定 安卓原生view
$element.bindAndroidView(button!);
}
updateText(text: string) {
//更新原生Button 文案描述
this.button?.setText(text)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录