zoukankan      html  css  js  c++  java
  • vue单引js写组件的总结

    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(); })


      

  • 相关阅读:
    CF703D Mishka and Interesting sum
    CF697D Puzzles
    SCOI2017酱油记
    [BZOJ4730][清华集训2016][UOJ266] Alice和Bob又在玩游戏
    BZOJ4311:向量
    BZOJ4520: [Cqoi2016]K远点对
    BZOJ4555: [Tjoi2016&Heoi2016]求和
    [Codechef November Challenge 2012] Arithmetic Progressions
    agc040
    补题
  • 原文地址:https://www.cnblogs.com/yangsg/p/12766636.html
Copyright © 2011-2022 走看看