nuxt.config.js
modules: [
// Doc: https://axios.nuxtjs.org/usage
// '@nuxtjs/axios',
// '@nuxtjs/proxy',
'@nuxtjs/axios'
]
index.vue
<template>
<div class="sp-policy">
<div>{{ Title }}</div>
<div v-html="Content">{{ Content }}</div>
</div>
</template>
<script>
import axios from 'axios'
export default {
components: {},
data() {
return {
Content: '',
Title: ''
}
},
async created() {
const res = await axios({
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
method: 'get',
url: `你要用到的api地址`,
data: ''
})
this.Content = unescape(res.data.result.content.replace(/\\u/g, '%u'))
this.Title = res.data.result.title
// const Content = unescape(res.data.result.content.replace(/\\u/g, '%u'))
// console.log(res)
// console.log(res.data.result.content)
},
methods: {}
}
</script>
<style lang="scss" scope>
.sp-policy {
align-items: center;
margin: 0 auto;
width: 1022px;
margin-top: 60px;
margin-bottom: 15px;
padding-left: 50px;
}
</style>