bubble.js 789 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // myComponents/bubble/bubble.js
  2. Component({
  3. properties: {
  4. // 气泡框显示时的样式
  5. showStyle: {
  6. type: Object,
  7. value: {}
  8. }
  9. },
  10. data: {
  11. // 控制气泡框的显示与隐藏
  12. show: false
  13. },
  14. methods: {
  15. // 显示气泡框
  16. showBubble() {
  17. this.setData({
  18. show: true
  19. });
  20. },
  21. // 隐藏气泡框
  22. hideBubble() {
  23. this.setData({
  24. show: false
  25. });
  26. }
  27. },
  28. lifetimes: {
  29. // 组件加载时设置初始样式
  30. attached() {
  31. const { showStyle } = this.properties;
  32. this.setData({
  33. containerStyle: showStyle.containerStyle || '',
  34. contentStyle: showStyle.contentStyle || ''
  35. });
  36. }
  37. }
  38. });