码迷,mamicode.com
首页 > Web开发 > 详细

vue单引js写组件的总结

时间:2020-04-24 12:58:21      阅读:66      评论:0      收藏:0      [点我收藏+]

标签:spl   逻辑   html   class   this   let   rap   调用   play   

 

html部分正常写 调用组件时

//写在body里面
<withdrawal-hongbao v-if="flagHongbao" :hongbao="hongbao"></withdrawal-hongbao>

//template 要写在body外面

<template id="withdrawal-notice" style="display: none;">
    <div id="hongbao-main">
        <div class="hongbao-con">
            <div id="hongbao-click" @click="goUrl()" data-url="{{hongbao.dataurl}}"></div>
            <div id="hongbao-close" @click="goClose()"></div>
        </div>
    </div>
</template>

JS部分

class Withdrawal {
  constructor() {
    this.init();
  }
  init() {
        let components = this.vueComponents();

        this.$vm = new Vue({
            el: ".wrapper",
            data: {
                   hongbao:{
                      url:"",    
                      sumAmt:"",    
                },
                flagHongbao:false,
               },
            methods: {
                hongBao: function() {//你的逻辑}     
            },
            components: components,
            })
  vueComponents() {
    let self = this;
return { withdrawalHongbao:self.getwithdrawalhongbao() }; } getwithdrawalhongbao(){ return Vue.extend({ template: "#withdrawal_hongbao", props: ["hongbao","flagHongbao"], methods:{ goClose(){ this.flagHongbao = false; document.getElementById("hongbao-main").style.display = "none"; }, goUrl(){} } }); } } $(function() { new Withdrawal(); })


  

vue单引js写组件的总结

标签:spl   逻辑   html   class   this   let   rap   调用   play   

原文地址:https://www.cnblogs.com/yangsg/p/12766636.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!