<view class="item flex2">
<text class="content" style="-webkit-line-clamp:{{line}}" bindtap="more">{{content}}</text>
</view>
<view class="item flex2">
<text class="content" style="-webkit-line-clamp:{{line}}" bindtap="more">{{content}}</text>
</view>
Page({
data: {
line:'4'
},
more(e){
this.setData({
line:'15'
})
}
})
点击以后2个内容都显示15行了,该如何修改才是单独的效果?
<view wx:for="{{items}}" wx:key="idx">
<view class="item flex2">
<text id="{{index}}" class="content" style="-webkit-line-clamp:{{item.line}}" bindtap="more">{{item.content}}</text>
</view>
</view>
Page({
data: {
items: [{
idx:0,
content: '1111',
line: '4'
}, {
idx:1,
content: '2222',
line: '4'
}]
},
你几个content难道不是放到一个数组里的吗
<view class="item flex2"> <text class="content" style="-webkit-line-clamp:{{line}}" bindtap="more">{{content}}</text> </view> <view class="item flex2"> <text class="content" style="-webkit-line-clamp:{{line1}}" bindtap="more1">{{content}}</text> </view> Page({ data: { line:'4' line1:'5' }, more(e){ this.setData({ line:'15' }) } more1(e){ this.setData({ line1:'14' }) } })
<view class="item flex2">
<text class="content" data-idx="1" style="-webkit-line-clamp:{{line}}" bindtap="more">{{content}}</text>
</view>
<view class="item flex2">
<text class="content" data-idx="2" style="-webkit-line-clamp:{{line1}}" bindtap="more">{{content}}</text>
</view>
Page({
data: {
line:'4'
line1:'5'
},
more(e){
if( e.currentTarget.dataset.idx="1"){
this.setData({
line:'15'
})
}else{
this.setData({
line1:'13'
})
}
}
})