1.它是一个button按钮,不是a标签,不可以改成router,那么怎么跳转呢
路由定义: {name:'goodsdesc',path:'/goods/goodsdesc/:goodsid',component:goodsdesc},
父组件:<mt-button @click="todesc" type="danger" size="large" plain>图文介绍</mt-button>
// 导航到图文介绍组件
todesc(){
// 如何利用js代码进行路由跳转
this.$router.push({ name: 'goodsdesc', params: { goodsid: this.goodsid }});
},
<div class="tmpl">
<h4>{{desc.title}}</h4>
<div v-html="desc.content"></div>
</div>
</template>
<script>
import common from '../../kits/common.js'
export default{
data(){
return {
desc:{}
}
},
created(){
// 根据商品id获取到图文信息
var url = common.apiDomain+'/api/goods/getdesc/'+this.$route.params.goodsid;
this.$http.get(url).then(res=>{
this.desc = res.body.message[0];
});
}
}
</script>
<style scoped>
</style>