javascript - Vue 3 和 Mixin:this.$el.querySelectorAll 不是函数
问题描述
当我尝试这个时:
createApp(App).mixin({
methods: {
myFunction() {
this.$el.querySelectorAll('input').forEach(...);
}
},
mounted() {
this.myFunction();
}
}).mount('#app');
我得到了一个TypeError: this.$el.querySelectorAll is not a function
但奇怪的是一切都按预期工作。所以 this.$el 被定义,querySelectorAll() 返回节点,我可以用 forEach() 遍历它们。这里有什么问题,我该如何摆脱错误?
解决方案
推荐阅读
- unit-testing - xunit 测试用例中未捕获的聚合异常
- java - 如何获取或读取 pom.xml 中“systemPropertyVariables”标签下定义的 Env 变量?
- android - 带有 Room 数据库的 Google play 游戏服务
- c - 当第二个输入 b 等于 0 时,如何得到预期的结果?
- java - oracle开发人员中的SQL日期比较
- r - lapply、dplyr 和使用列表中的值
- javascript - 如何在注册页面上添加名称字段?
- c# - 多次加载程序集的语义
- java - 用于删除 Airflow Dag 的 Rest Api 支持
- ios - Flutter 项目 - XCode 构建失败