提交 fe8e00f6 编写于 作者: DCloud_iOS_XHY's avatar DCloud_iOS_XHY

提交iOS平台 uts-hello-component 示例

上级 28822583
......@@ -10,12 +10,8 @@
LottieLoopMode
} from 'Lottie'
import {
URL,
Bundle
URL
} from 'Foundation'
import {
UIView
} from "UIKit"
import {
UTSiOS
} from "DCloudUTSFoundation"
......@@ -80,15 +76,15 @@
watch: {
"path": {
handler(newValue: string, oldValue: string) {
this.path = newValue
if (this.autoplay) {
this.playAnimation()
}
},
immediate: false //创建时是否通过此方法更新属性,默认值为false
},
"loop": {
handler(newValue: boolean, oldValue: boolean) {
this.loop = newValue
if (this.loop) {
if (newValue) {
this.$el.loopMode = LottieLoopMode.loop
} else {
this.$el.loopMode = LottieLoopMode.playOnce
......@@ -98,8 +94,7 @@
},
"autoplay": {
handler(newValue: boolean, oldValue: boolean) {
this.autoplay = newValue
if (this.autoplay) {
if (newValue) {
this.playAnimation()
}
},
......@@ -108,9 +103,7 @@
"action": {
handler(newValue: string, oldValue: string) {
const action = newValue
if (action == "play" || action == "pause" || action == "stop") {
this.action = action
switch (action) {
case "play":
this.playAnimation()
......@@ -133,7 +126,6 @@
"hidden": {
handler(newValue: boolean, oldValue: boolean) {
this.hidden = newValue
this.$el.isHidden = this.hidden
},
immediate: false //创建时是否通过此方法更新属性,默认值为false
......
<template>
<view>
<slot></slot>
</view>
</template>
<script lang="uts">
import {
UIView
} from 'UIKit'
//原生提供以下属性或方法的实现
export default {
name: "uts-hello-container",
NVLoad(): UIView {
let view = new UIView()
return view
}
}
</script>
<template>
<view class="defaultStyles">
</view>
</template>
<script lang="uts">
import {
UIButton,
UIControl
} from "UIKit"
// 定义按钮点击后触发回调的类
class ButtonClickListsner {
// 按钮点击回调方法
@objc buttonClick() {
console.log("按钮被点击")
}
}
//原生提供以下属性或方法的实现
export default {
name: "uts-hello-view",
emits: ['buttonClick'],
props: {
"buttonText": {
type: String,
default: "点击触发"
}
},
watch: {
"buttonText": {
/**
* 这里监听属性变化,并进行组件内部更新
*/
handler(newButtonText: string, oldButtonText) {
this.$el.setTitle(newButtonText, for = UIControl.State.normal)
},
immediate: false //创建时是否通过此方法更新属性,默认值为false
},
},
data() {
return {
buttonClickListsner : new ButtonClickListsner()
}
},
expose: ['doSth'],
methods: {
/**
* 对外公开的组件方法
*/
doSth(paramA: string) {
// 这是组件的自定义方法
console.log("paramA")
}
},
/**
* 创建原生View,必须定义返回值类型
*/
NVLoad(): UIButton {
//必须实现
let button = new UIButton()
button.setTitle(this.buttonText, for = UIControl.State.normal)
const method = Selector("buttonClick")
button.addTarget(this.buttonClickListsner, action = method, for = UIControl.Event.touchUpInside)
return button
}
}
</script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册