com.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // components/com/com.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. options: {
  7. multipleSlots: true, //在组件中定义时的选择项中 启用多个slot支持
  8. styleIsolation: "apply- q",
  9. pureDataPattern: /^_/
  10. },
  11. properties: {
  12. val: {
  13. type: String,
  14. value: 10
  15. },
  16. count: {
  17. type: String
  18. },
  19. obj: {
  20. type: Object
  21. }
  22. },
  23. /**
  24. * 组件的初始数据
  25. */
  26. data: {
  27. num: 0,
  28. isShow: true,
  29. _aa: 2
  30. },
  31. lifetimes: {
  32. attached: function () {
  33. // 在组件实例进入页面节点树时执行
  34. },
  35. detached: function () {
  36. // 在组件实例被从页面节点树移除时执行
  37. },
  38. },
  39. pageLifetimes: {
  40. show: function () {
  41. // 页面被展示
  42. },
  43. hide: function () {
  44. // 页面被隐藏
  45. },
  46. resize: function (size) {
  47. // 页面尺寸变化
  48. }
  49. },
  50. //监听器
  51. observers: {
  52. count: function (val) {
  53. console.log(val)
  54. }
  55. },
  56. /**
  57. * 组件的方法列表
  58. */
  59. methods: {
  60. //点击+1
  61. add(event) {
  62. // this.setData({
  63. // num: this.data.num + this.data.val * 1
  64. // })
  65. // console.log(this.data.val)
  66. // console.log(event)
  67. //第一个参数 事件名称
  68. //第二个参数 参数部分
  69. console.log(event)
  70. this.triggerEvent('myevent', {
  71. step: 5
  72. })
  73. }
  74. }
  75. })