服务端数据模式 数据初始化异常
官网的样例,在data 本地模式中,v-model绑定的数据,在select框初始化时会呈现数据,但是用 :data 服务端数据模式下,v-model绑定的数据初始化会出现异常
remote (initPicked = false) { if (typeof this.data === 'string' && this.dataLoad && typeof this.dataLoad === 'function') { const queryParams = this.params && Object.keys(this.params).length ? JSON.parse(JSON.stringify(this.params)) : {} queryParams.pageSize = this.pageSize queryParams.pageNumber = this.pageNumber if (this.sort) queryParams.orderBy = this.sort if (initPicked && this.value) { queryParams.searchKey = this.keyField queryParams.searchValue = this.value } if (this.search) { // this.searchField ? this.searchField : this.showField; if (!this.searchField && typeof this.showField === 'function') { // eslint-disable-next-line no-console console.error('Your "showField" was a function, in server side mode, your need specified "searchField" to search content.') } else { const field = this.searchField || this.showField queryParams[field] = this.search } } this.dataLoad(this, this.data, queryParams).then(resp => { if (resp) { if (!this.resultFormat || typeof this.resultFormat !== 'function') { // eslint-disable-next-line no-console console.error('In server side mode, you need specified "result-format" option(function type) to format server side response result.') } else { const tmpObj = this.resultFormat(resp) if (tmpObj && Object.keys(tmpObj).length) { if (!initPicked) { // load new page data list this.list = tmpObj.list this.totalRows = tmpObj.totalRow } else { // this.picked = tmpObj.list if (tmpObj.list != null && tmpObj.list != '' && Array.isArray(tmpObj.list)) { const arr = this.value.split(',') if (arr && arr.length) { const matchRows = tmpObj.list.filter(val => arr.includes(String(val[this.keyField]))) if (matchRows.length) { this.picked = this.multiple ? matchRows : [matchRows[0]] } } } }// the selected item info } } } }).catch(resp => { this.list = [] this.totalRows = 0 }) } }
我这么改的,目前是解决了
![]()
remote (initPicked = false) { if (typeof this.data === 'string' && this.dataLoad && typeof this.dataLoad === 'function') { const queryParams = this.params && Object.keys(this.params).length ? JSON.parse(JSON.stringify(this.params)) : {} queryParams.pageSize = this.pageSize queryParams.pageNumber = this.pageNumber if (this.sort) queryParams.orderBy = this.sort if (initPicked && this.value) { queryParams.searchKey = this.keyField queryParams.searchValue = this.value } if (this.search) { // this.searchField ? this.searchField : this.showField; if (!this.searchField && typeof this.showField === 'function') { // eslint-disable-next-line no-console console.error('Your "showField" was a function, in server side mode, your need specified "searchField" to search content.') } else { const field = this.searchField || this.showField queryParams[field] = this.search } } this.dataLoad(this, this.data, queryParams).then(resp => { if (resp) { if (!this.resultFormat || typeof this.resultFormat !== 'function') { // eslint-disable-next-line no-console console.error('In server side mode, you need specified "result-format" option(function type) to format server side response result.') } else { const tmpObj = this.resultFormat(resp) if (tmpObj && Object.keys(tmpObj).length) { if (!initPicked) { // load new page data list this.list = tmpObj.list this.totalRows = tmpObj.totalRow } else { // this.picked = tmpObj.list if (tmpObj.list != null && tmpObj.list != '' && Array.isArray(tmpObj.list)) { const arr = this.value.split(',') if (arr && arr.length) { const matchRows = tmpObj.list.filter(val => arr.includes(String(val[this.keyField]))) if (matchRows.length) { this.picked = this.multiple ? matchRows : [matchRows[0]] } } } }// the selected item info } } } }).catch(resp => { this.list = [] this.totalRows = 0 }) } }我这么改的,目前是解决了
if the data is on another page it will not work :( could you post the client code when working with data from the server side?