注意:<script type="text/javascript">标签是js下,而模板:<template id="upLoading">标签只能在html标签下,所以把模板做成js使用不了,只能写在当前HTML引用页面一起加载
HTML的使用:
<up-loading ref="ss"></up-loading>
<%- include('./../../../Main/views/vue_component/ui') %>
VUE 调用:
that.$refs.ss.Open('xxx');
Open为模板里的方法,ss不能有大写字母,不然无法识别。
<!-- UpLoading --> <template id="upLoading">
<div > <input v-show="show" id="fileSelect" name="fileSelect" @change="update" ref="inputer" type="file" multiple/>
</div>
</template>
<script type="text/javascript"> "use strict"; Vue.component('up-loading', { //不能有大写 template : '#upLoading', props: { drop: { default: false, }, value: { //前端传来的插槽值 type: Array, default: Array, }, }, data() { //写法不能改变 return{ show: true, files:[], } }, watch: { files:function () { console.log("file changed"); } }, methods: { update: function () { }, fileopen:function () { }, filepost:function () { }, //file列表删除 delfile:function (index) { //this.files.remove(index); }, unselect () { this.$refs.table1.unSelectAll() }, } }); </script>