小程序組件的繼承 - behavior


1.目錄結構

demo-one 和 demo-two 一起公用一些屬性 和 方法 存在demo-beh.js中

需要像模塊一樣導出

2.調用的方法:

 

// components/demo-class/demo-one/index.js
import { demoBeh } from '../demo-beh.js'
Component({
  /**
   * 組件的屬性列表
   */
  
  properties: {
    
  },

  // 多繼承
  behaviors: [demoBeh],

  attached:function(){
    // 通過behaviors繼承時 不會覆蓋 會依次執行 
  },
  /**
   * 組件的初始數據
   */
  data: {

  },

  /**
   * 組件的方法列表
   */
  methods: {

  }
})

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM