Vue element messageBox自定義多行內容


var Main = {
    methods: {
      open4() {
      //1.我們要將后台返回的數據轉存成數組,格式為: data=['錯誤提示一!!!','錯誤提示二!!!','錯誤提示三!!!'];
      let data = ['錯誤提示一!!!','錯誤提示二!!!','錯誤提示三!!!'];
     //2.新建newDatas數組
      let newDatas = [];
      const h = this.$createElement;
     //3.通過循環data數組,調用h方法,將每項值傳給h,h('標簽名',樣式,具體內容)
      for(let i in data){
     //4.將data數據push進newDatas數組中
          newDatas.push(h('p',null,data[i]));
      };
        this.$msgbox({
          title: '消息',
      //5.將newDatas傳進h方法生成的代碼格式為:
      // <div>
      //      <p>錯誤提示一!!!</p>
      //      <p>錯誤提示二!!!</p>
      //      <p>錯誤提示三!!!</p>
      // </div>
          message: h('div',null, newDatas),
          showCancelButton: true,
          confirmButtonText: '確定',
          cancelButtonText: '取消',
        }).then(action => {
          this.$message({
            type: 'info',
            message: 'action: ' + action
          });
        });
      },
      
    }
  }
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')

 


免責聲明!

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



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