纸通宝商家版本的小程序,原生微信开发。
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.
 

35 lines
915 B

Component({
options: {
addGlobalClass: true,
multipleSlots: true
},
properties: {
content: { type: String, value: '' },
keyword: { type: String, value: '' },
keywordColor: { type: String, value: '#008aff' }
},
observers: {
'keyword': function () {
this.setContent()
}
},
data: {
contain: false
},
methods: {
setContent: function () {
if(this.data.keyword == null || '' == this.data.keyword || this.data.keyword.length == 0){
this.setData({contain: false})
return
}
var index = this.data.content.indexOf(this.data.keyword)
if(index < 0){
this.setData({contain: false})
} else {
var textstrA = this.data.content.substring(0, index)
var textstrB = this.data.content.substring(index + this.data.keyword.length)
this.setData({contain: true, textstrA, textstrB})
}
}
}
})