<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        使用Vue做一個簡單的todo應用的三種方式的示例代碼

        來源:懂視網 責編:小采 時間:2020-11-27 22:06:06
        文檔

        使用Vue做一個簡單的todo應用的三種方式的示例代碼

        使用Vue做一個簡單的todo應用的三種方式的示例代碼:1. 引用vue.js <!DOCTYPE html> <html> <head> <script src=http://vuejs.org/js/vue.js></script> <meta charset=utf-8> <title>JS Bin</ti
        推薦度:
        導讀使用Vue做一個簡單的todo應用的三種方式的示例代碼:1. 引用vue.js <!DOCTYPE html> <html> <head> <script src=http://vuejs.org/js/vue.js></script> <meta charset=utf-8> <title>JS Bin</ti

        1. 引用vue.js

        <!DOCTYPE html>
        <html>
        <head>
        <script src="http://vuejs.org/js/vue.js"></script>
         <meta charset="utf-8">
         <title>JS Bin</title>
        </head>
        <body>
         <div id="root">
         <input type="text" v-model="inputValue">
         <button @click="handlerAdd">提交</button>
         <ul>
         <li 
         v-for="(item,index) of lists" 
         :key="index" 
         @click="handlerDel(index)"
         >
         {{item}}
         </li>
         </ul>
         </div>
         
         <script>
         new Vue({
         el: '#root',
         data: {
         inputValue: '',
         lists: []
         },
         methods: {
         handlerAdd: function() {
         this.lists.push(this.inputValue);
         this.inputValue = '';
         },
         handlerDel: function(index) {
         this.lists.splice(index, 1);
         }
         }
         });
         </script>
        </body>
        </html>

        2. 全局組件注冊

        <!DOCTYPE html>
        <html>
        <head>
        <script src="http://vuejs.org/js/vue.js"></script>
         <meta charset="utf-8">
         <title>JS Bin</title>
        </head>
        <body>
         <div id="root">
         <input type="text" v-model="inputValue">
         <button @click="handlerAdd">提交</button>
         <ul>
         <todo-item
         v-for="(item,index) of lists"
         :content = "item"
         :index = "index"
         :key = "index"
         @delete="handlerDel"
         >
         </todo-item>
         </ul>
         </div>
         
         <script>
         Vue.component('todoItem', {
         props: {
         content: String,
         index: Number
         },
         template: '<li @click="handlerClick">{{content}}</li>',
         methods: {
         handlerClick: function(){
         this.$emit('delete', this.index);
         }
         }
        
         });
        
         new Vue({
         el: '#root',
         data: {
         inputValue: '' ,
         lists: []
         },
         methods: {
         handlerAdd: function() {
         this.lists.push(this.inputValue);
         this.inputValue = '';
         },
         handlerDel: function(index) {
         this.lists.splice(index,1);
         }
         }
         });
         </script>
        </body>
        </html>
        

        3. vue-cli腳手架

        // Todo.Vue
        
        <template>
         <div>
         <input type="text" v-model="inputValue">
         <button @click="handlerAdd">提交</button>
         <ul>
         <todo-item
         v-for="(item,index) of lists"
         :key="index"
         :content="item"
         :index="index"
         @delete="handlerDel"
         ></todo-item>
         </ul>
         </div>
        </template>
        
        <script>
        import TodoItem from './components/todoItem'
        
        export default {
         data () {
         return {
         inputValue: '',
         lists: []
         }
         },
         methods: {
         handlerAdd () {
         this.lists.push(this.inputValue)
         this.inputValue = ''
         },
         handlerDel (index) {
         this.lists.splice(index, 1)
         }
         },
         components: {
         'todo-item': TodoItem
         }
        }
        </script>
        
        <style>
        
        </style>
        // TodoItem.vue
        
        <template>
         <li @click="handlerClick" class="item">{{content}}</li>
        </template>
        
        <script>
        export default {
         props: ['content', 'index'],
         methods: {
         handlerClick () {
         this.$emit('delete', this.index)
         }
         }
        }
        </script>
        
        <style scoped>
         ul,li {
         list-style: none;
         }
         .item {
         color: blueviolet;
         }
        </style>
        

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        使用Vue做一個簡單的todo應用的三種方式的示例代碼

        使用Vue做一個簡單的todo應用的三種方式的示例代碼:1. 引用vue.js <!DOCTYPE html> <html> <head> <script src=http://vuejs.org/js/vue.js></script> <meta charset=utf-8> <title>JS Bin</ti
        推薦度:
        標簽: 方法 VUE 代碼
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 久久精品国产亚洲综合色| 亚洲第一成年网站大全亚洲| 国产成人精品日本亚洲专| 亚洲欧洲日产国码二区首页 | 天黑黑影院在线观看视频高清免费 | www.亚洲精品| 丰满少妇作爱视频免费观看| 国产精品99精品久久免费| 国产精品免费精品自在线观看| 亚洲最大成人网色| 美女被免费网站在线视频免费| 国产精品冒白浆免费视频 | 一级毛片免费在线播放| 亚洲人妻av伦理| 亚洲午夜电影在线观看| 999在线视频精品免费播放观看| 亚洲国产91在线| 国产一卡二卡≡卡四卡免费乱码| 小说专区亚洲春色校园| 中文字幕第一页亚洲| 香港a毛片免费观看| 国产成人精品日本亚洲专区| aa级女人大片喷水视频免费| 亚洲无删减国产精品一区| 男男gay做爽爽的视频免费| 久久久久久久91精品免费观看 | 亚洲成人免费网站| 免费无遮挡无码视频网站| 中文字幕亚洲第一在线| 久久久久久久91精品免费观看| 国产亚洲精品第一综合| 亚洲色欲色欲www在线丝| 一级一看免费完整版毛片| 久久久久亚洲精品无码系列| 免费H网站在线观看的| 免费国产a理论片| 久久精品国产亚洲AV无码偷窥| 天天摸天天操免费播放小视频| 一级做a免费视频观看网站| 亚洲视频日韩视频| 国产免费av片在线播放|