test.js 933 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // components/test/test.js
  2. Component({
  3. options: {
  4. styleIsolation: 'shared'
  5. },
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {
  10. // 第一种方式:简化的方式
  11. // max: Number
  12. // 第二种方式:完整的定义方式
  13. max: {
  14. type: Number,
  15. value: 10
  16. }
  17. },
  18. /**
  19. * 组件的初始数据
  20. */
  21. data: {
  22. count: 0
  23. },
  24. /**
  25. * 组件的方法列表
  26. */
  27. methods: {
  28. // 点击事件处理函数
  29. addCount() {
  30. if (this.data.count >= this.properties.max) return
  31. this.setData({
  32. count: this.data.count + 1,
  33. max: this.properties.max + 1
  34. })
  35. this._showCount()
  36. },
  37. _showCount() {
  38. wx.showToast({
  39. title: 'count是' + this.data.count,
  40. icon: 'none'
  41. })
  42. },
  43. showInfo() {
  44. console.log(this.data)
  45. console.log(this.properties)
  46. console.log(this.data === this.properties)
  47. }
  48. }
  49. })