国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

使用vue實(shí)現(xiàn)通過變量動態(tài)拼接url

瀏覽:99日期:2022-12-30 10:48:43

如何通過變量動態(tài)拼接url?

格式:<a :href='http://www.intensediesel.com/bcjs/’index.shtml?other=’+object.name' rel='external nofollow' rel='external nofollow' >這是一個動態(tài)鏈接</a>

需要注意的是href前要加上冒號,href最外層是雙引號,中間是單引號。

<div id='datatable'><div v-for='(object,index) in items'><!-格式如下,href前要加上冒號---> <a :href='http://www.intensediesel.com/bcjs/’index.shtml?other=’+object.name' rel='external nofollow' rel='external nofollow' >這是一個動態(tài)鏈接</a></div></div><script> $(document).ready(function() { App.init(); //數(shù)據(jù)列表 var datatable = new Vue({ el: ’#datatable’, data: {items: [], }, }); //從服務(wù)端獲取數(shù)據(jù) getList(); function getList() { $.ajax({url : '/sapi/getcluster',type : 'post',dataType : 'json',success : function(result){ if(result.status == -1){ window.location.href = result.data; return false; } datatable.items = result.data['XXX'];} }); } });</script>

動態(tài)拼接結(jié)果為:

href=“index.shtml?other=yyy”

補(bǔ)充知識:vue全局變量apiurl

1、定義

在main.js里面定義

Vue.prototype.$apiUrl = ' http://xxxxxxxxxx';

2、使用

在聯(lián)調(diào)的時(shí)候

url: this.$apiUrl + '/xxxx(端口)'

以上這篇使用vue實(shí)現(xiàn)通過變量動態(tài)拼接url就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 湖口县| 永丰县| 金乡县| 桃园县| 满洲里市| 将乐县| 哈尔滨市| 祁门县| 双桥区| 阜宁县| 绥宁县| 崇阳县| 离岛区| 盐边县| 迁安市| 油尖旺区| 仁寿县| 霍邱县| 乌苏市| 上林县| 屏边| 武穴市| 满城县| 治多县| 泸溪县| 定襄县| 顺昌县| 汝南县| 象州县| 聂拉木县| 普兰店市| 茂名市| 靖安县| 南昌市| 浦江县| 军事| 资中县| 昌邑市| 稻城县| 惠东县| 鄯善县|