uniapp中使用富文本进行展示

<template>
	<view>
		<rich-text :nodes="change(string)"></rich-text>
	</view>
</template>

<script>
	import server from @/api/index.js
	export default {
		data() {
			return {
				string: ,
			};
		},
		onLoad() {
		    this.getysxy();
		},
		methods: {
			getysxy(){
				server.getysxy().then(res =>{
					console.log(隐私协议,res)
					this.string = res;
					if(res.length > 0){
						this.string = res.value;
					}
				})
			},
			change(data){
				if(data){
					let html = data.replace(/<img([sw"-=/.:;]+)((?:(height="[^"]+")))/ig, <img$1)
					.replace(/<img([sw"-=/.:;]+)((?:(width="[^"]+")))/ig, <img$1)
					.replace(/<img([sw"-=/.:;]+)((?:(style="[^"]+")))/ig, <img$1)
					.replace(/<img([sw"-=/.:;]+)((?:(alt="[^"]+")))/ig, <img$1)
					.replace(/<img([sw"-=/.:;]+)/ig, <img style="width: 100%;" $1);
					return html
				}
			}
		}
	}
</script>

<style lang="scss">

</style>
经验分享 程序员 微信小程序 职场和发展