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

js 使用script或template标签:分离js代码template中的HTML元素

时间:2019-09-04 19:06:30      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:first   nbsp   lan   col   元素   pre   rip   方法   get   

参考:https://www.jianshu.com/p/332252abe016

方法一. script:

<div id="app">
      <com-first></com-first>
 </div>
 <script type="text/x-template" id="comFirst">
      <div>component 1</div>
  </script>
<script> 
        Vue.component(‘com-first‘,{
            template: ‘#comFirst‘
        })
        
        new Vue({
            el: ‘#app‘
        })        
</script>

方法二. template:

<div id="app">
      <com-first></com-first>
</div>
<template id="comFirst">
      <div>component 1</div>
</template>
<script>
     Vue.component(‘com-first‘,{
            template: ‘#comFirst‘
        })
        
        new Vue({
            el: ‘#app‘
        })
</script>

 

js 使用script或template标签:分离js代码template中的HTML元素

标签:first   nbsp   lan   col   元素   pre   rip   方法   get   

原文地址:https://www.cnblogs.com/linjiangxian/p/11460886.html

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