<template>
  <div class="newsDetails">
    <div class="newscont">
      <h1>{{this.formData.title}}</h1>
      <div class="content" v-html="this.formData.content"></div>
    </div>

  </div>
</template>

<script>
export default {
  data() {
    return {
       id: 11,
       aid: '',
       formData: {}
    };
  },
  created() {
    this.getUrlsub();
    this.loadData();
  },
  methods: {
    async loadData() {
      const response = await this.$http.get(`biz/newsArticle/${this.aid}`);
      if (response.data.code === 1) {
        this.formData = response.data.responseData;
      }
    },
    //获取url斜杠最后的一个字段
    getUrlsub() {
      var urlStr = location.pathname;
      var index = urlStr.lastIndexOf('\/');
      this.aid = urlStr.substring(index + 1, urlStr.length);
    }

  }
};
</script>

<style>
.newsDetails {
  background-color: #f8f8f9;
}
.newsDetails .newscont {
  width: 700px;
  margin: 0 auto;
  overflow: hidden;
}
.newsDetails .newscont h1{
  font-size: 30px;
  margin: 20px auto;
  text-align: center;
}
.newsDetails .newscont .content{
  font-size: 16px;
}
.newsDetails .newscont .content img {
  width: 100%;
}
</style>

