在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ vue使用了template組件后怎么繼續(xù)使用自定義組件?

vue使用了template組件后怎么繼續(xù)使用自定義組件?

<template>
    <div class="auth">
        <el-form :model="form" :rules="rules2" ref="form">
            <div class="panfish">
                <img :src="imgurl" :class="topimg"/>
            </div>
            <div class="panel">
                <h1 class="title">Sign IN</h1>
                <div class="input-group">
                    <div class="input-box">
                        <el-form-item prop="username">
                            <el-input type="text" v-model="form.username" auto-complete="off" placeholder="賬號(hào)" @focus="username()" @blur="none()"></el-input>
                        </el-form-item>
                    </div>
                    <div class="input-box">
                        <el-form-item prop="password">
                            <el-input type="password" v-model="form.password" auto-complete="off" placeholder="密碼" @focus="password()" @blur="none()"></el-input>
                        </el-form-item>
                    </div>
                </div>
                <el-button type="primary" class="btn" v-loading="loading" @click.native.prevent="handleSubmit2('form')">登錄</el-button>
            </div>
        </el-form>
    </div>
</template>
<script>
  export default {
    components: {
      'remote-js': {
        render(createElement) {
          return createElement('script', { attrs: { type: 'text/javascript', src: this.src }});
        },
      props: {
        src: { type: String, required: true },
        },
      },
    },
   }
</script>

在網(wǎng)上找到了這個(gè)方法引入外部js

<remote-js src="https://g.alicdn.com/dingding/dinglogin/0.0.2/ddLogin.js">
</remote-js>

但是現(xiàn)在這個(gè)自定義組件放在template里面會(huì)報(bào)錯(cuò),放在外面不引用,請(qǐng)問正確的使用姿勢(shì)是怎樣?

回答
編輯回答
萌面人

你可以放在index.html上。。。我的微信全局js也是放在index.html里面的。

    'remoteJs': {
                render(createElement) {
                    return createElement('script', {attrs: {type: 'text/javascript', src: this.src}});
                },

注意你的remoteJs的名字要用駝峰規(guī)則

2018年8月9日 17:34
編輯回答
淚染裳

謝邀。
不是很明白你的意思,如果是想寫一個(gè)自定義組件,那么寫好這個(gè)文件,在需要的地方引入,在components里面注冊(cè)好,然后就可以在需要的地方用了。
父子組件porps傳參:

<parent>
<child:key1="v1" :key2="v2" />
</parent>
//child.vue
props:{
  key1:{
    //這里可以指定傳參的格式什么的
    },
  key2:{}
}
2018年9月17日 20:40