修复渲染失败页面监听错误的问题

This commit is contained in:
maplemei 2020-12-04 16:39:55 +08:00
parent 16de57e340
commit b47c8cfcb9
4 changed files with 26 additions and 15 deletions

View File

@ -25,7 +25,6 @@ var demo1 = xmSelect.render({
list: ['ALL', 'REVERSE', 'CLEAR']
},
filterable: true,
height: 'auto',
data(){
return [
{name: '销售员', value: -1, disabled: true, children: [

View File

@ -10,36 +10,36 @@
"author": "",
"license": "ISC",
"dependencies": {
"babel-polyfill": "^6.26.0",
"clean-webpack-plugin": "^3.0.0",
"element-ui": "^2.12.0",
"highlight.js": "^9.15.10",
"preact": "^10.4.6",
"vue": "^2.6.11",
"vue-router": "^3.1.3"
},
"devDependencies": {
"@babel/core": "^7.4.0",
"@babel/preset-env": "^7.4.2",
"babel-loader": "^8.0.5",
"babel-plugin-transform-react-jsx": "^6.24.1",
"babel-polyfill": "^6.26.0",
"clean-webpack-plugin": "^3.0.0",
"cross-env": "^6.0.0",
"css-loader": "^3.0.0",
"element-ui": "^2.12.0",
"file-loader": "^4.2.0",
"highlight.js": "^9.15.10",
"html-webpack-plugin": "^3.2.0",
"less": "^3.9.0",
"less-loader": "^4.1.0",
"markdown-it": "^10.0.0",
"markdown-it-anchor": "^5.2.4",
"markdown-it-chain": "^1.3.0",
"markdown-it-container": "^2.0.0",
"preact": "^10.4.6",
"style-loader": "^0.23.1",
"transliteration": "^2.1.7",
"url-loader": "^2.1.0",
"vue": "^2.6.10",
"vue-loader": "^15.7.1",
"vue-router": "^3.1.3",
"vue-template-compiler": "^2.6.10",
"webpack": "^4.29.6",
"webpack-cli": "^3.3.0",
"webpack-dev-server": "^3.2.1"
},
"devDependencies": {
"html-webpack-plugin": "^3.2.0"
}
}

View File

@ -26,6 +26,7 @@ class xmOptions {
//记录最新的配置项
this.options = deepMerge(this.options, options);
this.options.__render_success = false;
//如果dom不存在, 则不进行渲染事项
let { dom } = this.options;
@ -46,6 +47,8 @@ class xmOptions {
render(<Framework { ...this.options } __update={ Date.now() } updateData={ updateData } />, dom);
this.options.__render_success = true;
//返回多选对象
return this;
}
@ -252,6 +255,15 @@ class xmOptions {
return this;
}
/**
* 滚动到某个选项
*/
scroll(val){
let opt = this.options.dom.querySelector(`.xm-option[value="${ val }"]`);
opt && opt.scrollIntoView(false)
return this;
}
}
export default xmOptions;

View File

@ -23,7 +23,7 @@ export default {
let instance = new Select(options);
//已经渲染
if (instance) {
if (instance && instance.__render_success) {
datas[el] = instance;
}
return instance;