<template>
<div class="tmpl">
<!-- 1.0 標題 -->
<div class="twarp">
<h2 v-text="info.title"></h2>
<span class="desc">
{{info.add_time | datefmt}}
{{info.click}}次瀏覽
分類:民生
</span>
</div>
<!-- 2.0 新聞詳細展示區域 -->
<div class="content" v-html="info.content"></div>
<!-- 3.0 評論組件 -->
<comment :artid="newsid"></comment>
</div>
</template>
<script>
import common from '../../kits/common.js';
import { Toast } from 'mint-ui';
// 1.0 導入評論組件對象
import comment from '../subcom/comment.vue';
export default{
data(){
return {
info:{},
newsid:0
}
},
methods:{
getinfo(){
// 1.0 獲取url傳入的newsid
var newsid = this.$route.params.newsid;
this.$http.get(common.apiDomain+'/api/getnew/'+newsid)
.then(res=>{
if(res.body.status !==0){
Toast(res.body.message);
return;
}
this.info = res.body.message[0];
});
}
},
created(){
// 初始化newsid
this.newsid = this.$route.params.newsid;
this.getinfo();
},
// 使用comment 組件
components:{
comment // comment:comment
}
}
</script>
<style scoped>
.twarp h2{
color:#0094ff;
font-size:16px;
}
.twarp .desc{
color:rgba(0,0,0,0.4);
}
.twarp{
padding:10px;
border-bottom: 1px solid rgba(0,0,0,0.4);
}
.content{
padding:5px;
}
</style>
5.Vue之組件(模版)
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
- 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
- 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
- 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
推薦閱讀更多精彩內容
- 下載安裝搭建環境 可以選npm安裝,或者簡單下載一個開發版的vue.js文件 瀏覽器打開加載有vue的文檔時,控制...