這篇文章給大家分享的是有關(guān)vue-resourse怎么獲取json并應(yīng)用到模板的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),秀山土家族苗族企業(yè)網(wǎng)站建設(shè),秀山土家族苗族品牌網(wǎng)站建設(shè),網(wǎng)站定制,秀山土家族苗族網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,秀山土家族苗族網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競爭力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
代碼如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>vue js</title> <style> .completed { text-decoration: line-through; } .something { color: red; } </style> </head> <body> <div class="container"> <div id="app"> <task-app :list="tasks"> </task-app> </div> <template id="task-template"> <ul> <li v-for="task in list"> {{ task.id }} | {{ task.author }} | {{ task.name }} | {{ task.price }} </li> </ul> </template> <script src="vue.js"></script> <script src="vue-resource.js"></script> <script> Vue.component('task-app', {//要應(yīng)用的標(biāo)簽 template: '#task-template',//模板id props: ['list']//請求的json }) </script> <script> var demo = new Vue({ el: '#app', data: { tasks: '' //為空,可以是null }, ready: function() { this.getCustomers() }, methods: { getCustomers: function() { this.$http.get('resourse.json') .then(function(response) { //response傳參,可以是任何值 this.$set('tasks', response.data) }) .catch(function(response) { console.log(response) }) } } }) </script> </body> </html>
感謝各位的閱讀!關(guān)于“vue-resourse怎么獲取json并應(yīng)用到模板”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
網(wǎng)頁名稱:vue-resourse怎么獲取json并應(yīng)用到模板
標(biāo)題路徑:http://chinadenli.net/article34/ppscse.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器、品牌網(wǎng)站設(shè)計、自適應(yīng)網(wǎng)站、ChatGPT、網(wǎng)站導(dǎo)航、商城網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)