1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- Component({
- properties: {
- list: {
- type: Array
- },
- name: {
- type: String,
- value: "brandname"
- },
- active: {
- type: String,
- value: 0
- },
- rowIndex: {
- type: Number,
- value: 0
- },
- onChange: {
- type: Function
- }
- },
- externalClasses: [
- "box-class", "tab-class", "active-class"
- ],
- data: {
- scrollLeft: 0,
- },
- lifetimes: {
- attached: function () {
- getApp().globalData.Language.getLanguagePackage(this)
- }
- },
- methods: {
- onClick(e) {
- const {
- index,
- item
- } = e.currentTarget.dataset;
- if (this.data.active != index) {
- this.setData({
- active: index
- });
- this.triggerEvent("onChange", {
- item,
- index,
- rowIndex: this.data.rowIndex
- })
- this.setActive(index);
- }
- },
- setActive(active) {
- const that = this,
- query = wx.createSelectorQuery().in(this)
- query.select('#active' + active).boundingClientRect(function (res) {
- that.setData({
- scrollLeft: res.right - res.width
- })
- }).exec();
- },
- }
- })
|