init
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
.com2-container {
|
||||
background-color: yellow;
|
||||
margin: 20px;
|
||||
height: 250px;
|
||||
color: black;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
Component({
|
||||
properties: {
|
||||
message: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
data: {
|
||||
// 这里是一些组件内部数据
|
||||
someData: {}
|
||||
},
|
||||
methods: {
|
||||
onTap() {
|
||||
this.triggerEvent('myevent', {
|
||||
data: '自定义组件内触发triggerEvent'
|
||||
});
|
||||
},
|
||||
|
||||
onClear() {
|
||||
console.log('onClear com2', this);
|
||||
this.triggerEvent('myevent', {
|
||||
data: ''
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"component": true,
|
||||
"styleIsolation": "apply-shared"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<view class="com2-container">
|
||||
<view style="text-align: center;">这是子组件</view>
|
||||
<view style="text-align: center;">{{message}}</view>
|
||||
<view class="_ui-space _px10 _pt10">
|
||||
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="onTap">通过事件给父组件发消息</button>
|
||||
</view>
|
||||
</view>
|
||||
Reference in New Issue
Block a user