this.echartsIntance.on("legendselectchanged", function (params) { console.log("legendselectchanged" + JSON.stringify(params)); }); 第一次点击没有反应
时间: 2023-07-16 21:13:26 浏览: 31
可能是因为在第一次点击时,`echartsIntance`对象还没有初始化完成。你可以尝试在`echartsIntance`对象初始化完成后再绑定`legendselectchanged`事件。可以在`echartsIntance`对象的`init`方法中,使用`on`方法绑定事件,例如:
```
this.echartsIntance = echarts.init(document.getElementById('chart'));
this.echartsIntance.setOption(option);
this.echartsIntance.on("legendselectchanged", function (params) {
console.log("legendselectchanged" + JSON.stringify(params));
});
```
这样在`echartsIntance`对象初始化完成后,就会绑定`legendselectchanged`事件了。
相关问题
form.on('submit(data-search-btn)', function (data) { console.log(data.field); var result = JSON.stringify(data.field); //执行搜索重载 table.reload('currentTableId', { page: { curr: 1 } , where: { Params:result } }, 'data');
这段代码是一个表单提交事件的处理函数。当用户点击页面上的搜索按钮时,会触发表单提交事件,然后执行这个函数。函数中首先打印出表单数据,然后将表单数据转换成 JSON 字符串,接着通过调用 layui 表格组件的 reload 方法来重新加载表格数据。
其中,table.reload 方法第一个参数是当前表格的 id,第二个参数是一个配置对象,包含两个属性:page 和 where。其中,page 对象用于配置分页信息,where 对象用于配置查询条件。在这里,我们将查询条件设置为表单数据,然后重新加载表格数据。
如何使用这个方法/* promise形式接口调用 */ req: function (action, _param, noToken=false) { return new Promise((resolve,reject)=>{ var urlObj = {} noToken ? urlObj = api.getCommon(action): urlObj = api.getToken(action); var params = { process: urlObj['process'] || "", activity: urlObj['activity'] || "", action: urlObj['action'] || "", url: this.rootPath, params: JSON.stringify(_param), checkToken: noToken?false:true };
要使用这个方法,你可以按照以下步骤进行操作:
1. 确保已经正确引入了包含该方法的文件,并创建一个实例对象(假设为 `example`)。
2. 调用 `example.req()` 方法,并传入相应的参数。
3. 使用 `.then()` 和 `.catch()` 方法来处理 Promise 的结果和错误。
示例代码如下:
```javascript
// 引入包含 req 方法的文件,并创建一个实例对象
const example = require('example.js');
// 调用 req 方法,并传入参数
example.req('action', { param1: 'value1', param2: 'value2' })
.then(result => {
// 处理成功的结果
console.log(result);
})
.catch(error => {
// 处理错误
console.error(error);
});
```
在上述代码中,我们假设已经正确引入了包含 `req` 方法的 `example.js` 文件,并创建了一个 `example` 的实例对象。然后,我们调用 `example.req()` 方法并传入相应的参数。接着,使用 `.then()` 来处理成功的结果,使用 `.catch()` 来处理错误。可以使用 `console.log()` 来打印结果,或者使用其他逻辑来处理返回的数据。
相关推荐
![.zip](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)