123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- // components/com/com.js
- Component({
- /**
- * 组件的属性列表
- */
- options: {
- multipleSlots: true, //在组件中定义时的选择项中 启用多个slot支持
- styleIsolation: "apply- q",
- pureDataPattern: /^_/
- },
- properties: {
- val: {
- type: String,
- value: 10
- },
- count: {
- type: String
- },
- obj: {
- type: Object
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- num: 0,
- isShow: true,
- _aa: 2
- },
- lifetimes: {
- attached: function () {
- // 在组件实例进入页面节点树时执行
- },
- detached: function () {
- // 在组件实例被从页面节点树移除时执行
- },
- },
- pageLifetimes: {
- show: function () {
- // 页面被展示
- },
- hide: function () {
- // 页面被隐藏
- },
- resize: function (size) {
- // 页面尺寸变化
- }
- },
- //监听器
- observers: {
- count: function (val) {
- console.log(val)
- }
- },
- /**
- * 组件的方法列表
- */
- methods: {
- //点击+1
- add(event) {
- // this.setData({
- // num: this.data.num + this.data.val * 1
- // })
- // console.log(this.data.val)
- // console.log(event)
- //第一个参数 事件名称
- //第二个参数 参数部分
- console.log(event)
- this.triggerEvent('myevent', {
- step: 5
- })
- }
- }
- })
|