货无忧
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

37 lines
773 B

<template>
<view style="padding-top: 150rpx;">
<view v-html="html"></view>
</view>
</template>
<script>
export default {
data() {
return {
arrs:[{
age:'13',
name:'小绿',
sex:'男'
},{
age:'10',
name:'小王',
sex:'女'
}],
htmls:'<strong>Hello, {{name}}{{age}}{{sex}}!</strong>',
html:'',
// keys:[],
names: ['Alice', 'Bob', 'Charlie'] // 后端返回的数组
};
},
mounted () {
this.arrs.map(item=>{
let strhtml=JSON.parse(JSON.stringify(this.htmls))
for(let key in item){
strhtml=strhtml.replace(`{{${key}}}`,item[key])
}
console.log(strhtml);
this.html+=strhtml
})
},
};
</script>