// in js
data: {
type: '图片'
},
toggle: function(e) {
var that = this;
var type = that.data.type === '图片' ? '文字' : '图片';
that.setData({
type: type
});
}
Write two pages and set a bool variable onlyText to store the status. When it is true, the text version will be displayed, and when it is false, the picture version will be displayed. It looks like this:
Define a field xxxx in data
View here, determine which view needs to be displayed through conditional rendering
Click the button to change the value of xxxx
Write two pages and set a bool variable onlyText to store the status. When it is true, the text version will be displayed, and when it is false, the picture version will be displayed.
It looks like this: