|
|
|
@ -0,0 +1,35 @@ |
|
|
|
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}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |