按下按钮后,我正在尝试将新的 html 添加到我的 div 中,使用v-for
.
但是在我按下按钮后,我收到此错误并且元素(文章)被添加到 div 一次,但之后它将不再起作用。
vue.js?3de6:1743 TypeError: 无法读取属性 '_withTask' of undefined
at remove$2 (eval at (app.js:561), :7078:13)
at updateListeners (eval at (app.js:561), : 2067:7)
at Array.updateDOMListeners (eval at (app.js:561),:7091:3)
at patchVnode (eval at (app.js:561), :5918:62)
at updateChildren (eval at ( app.js:561),:7091:3) js:561), :5809:9)
at patchVnode (eval at (app.js:561), :5923:29)
at updateChildren (eval at (app.js:561), :5809:9)
at patchVnode (eval at (app.js:561), :5923:29)
at updateChildren (eval at (app.js:561), :5809:9)
at patchVnode (eval at (app.js:561), :5923:29)
HTML代码:
<article …
Run Code Online (Sandbox Code Playgroud) 我有一个 vue.js 脚本,它在一个方法中生成一个元素“镜头”。现在,我想添加一个 EventListener,它在单击镜头元素时调用另一个方法。
问题:
我尝试了两种不同的方法来添加侦听器。
1:有效lens.addEventListener("click", this.openLightbox(src));
但在页面加载时执行,而不是在点击时执行
2:lens.addEventListener("click", function() { this.openLightbox(src) }, false);
在点击而不是在有效载荷上执行,但抛出错误:Uncaught TypeError: this.openLightbox is not a function
The question:
How can I call the lightbox method in my zoom method? I does work if I copy the code from the lightbox mehtod into the zoom method itself as a function, however since the lightbox method is called by other elements as well that would lead to duplicate code.
Here is the full …
我目前正在测试 Vue.js,并在我的项目中使用了一些引用。我不确定是否每次在我的方法中调用 ref 时都会执行 DOM Lookup,或者 vue 是否将所有 ref 存储一次然后访问该引用。
我无法在文档中或通过谷歌找到答案。
例子
myDiv = this.$refs.myDiv
Run Code Online (Sandbox Code Playgroud)
我是否需要自己将 ref 存储在变量中,或者多次调用 ref 时是否没有性能影响?
我试图将工作日的字符串值转换为数字.
我正在调查Enum DayOfWeek
(https://docs.oracle.com/javase/8/docs/api/java/time/DayOfWeek.html),但它不能按我预期的方式工作.
码
String n = "MONDAY";
System.out.println(n); //prints MONDAY
System.out.println(DayOfWeek.valueOf(n)); //also prints MONDAY - should print 1
Run Code Online (Sandbox Code Playgroud)
如何从字符串中获取相应的数字呢?
我在我的应用程序中添加了一个 Bootstrap Vue 表,并希望在用户使用内置分页切换到另一个页面时进行记录。
https://bootstrap-vue.js.org/docs/components/table/
为此,我添加了一个@change
应该监听和记录分页的 v 模型的currentPage
. 但是,它似乎是在currentPage
实际更新之前调用的。
我如何才能正确收听此更新?
这是我尝试过的:https : //jsfiddle.net/eywraw8t/394424/
new Vue({
el: "#app",
data: {
totalRows: 50,
perPage: 10,
currentPage: 1
},
methods: {
pagination() {
console.log(this.currentPage);
},
}
})
Run Code Online (Sandbox Code Playgroud)
<div id="app">
<div>
<b-pagination :total-rows="totalRows" :per-page="perPage" v-model="currentPage" @change="pagination" />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我正在尝试将 NumberValue 格式化为当前区域设置格式的字符串。
\n\n例如,对于 Locale.Germany,这些将是我试图获得的结果:
\n\n1 -> 1,00\n1.1 -> 1,10\n0.1 -> 0,10\n
Run Code Online (Sandbox Code Playgroud)\n\n我尝试过的:
\n\nString test1 = NumberFormat.getInstance().format(1.1);\n// -> 1,1\nString test2 = NumberFormat.getCurrencyInstance().format(1.1);\n// -> 1,10 \xe2\x82\xac\n
Run Code Online (Sandbox Code Playgroud)\n\n如何获得与第二个示例相同的格式,而不使用货币符号?或者,我如何确保第一个示例的结果始终具有当前区域设置所需的小数位数?
\n\n编辑:由于有些货币有 0、2 或 3 位小数,我认为将小数设置为固定金额不会产生正确的结果。
\n\n此外,有些货币的符号在前面,有些在后面,因此切断最后一个字符可能也不起作用。
\n\nhttp://apps.cybersource.com/library/documentation/sbc/quickref/currencies.pdf
\n我有一个包含错误列表的集合.我想通过密钥(UUID UserId)对它们进行分组.为此,我复制了这个答案的代码:https: //stackoverflow.com/a/30202075/4045364
Collection<FilterError> filterErrors = new ArrayList<FilterError>();
// ... some filterErrors get added to the collection ...
return filterErrors.stream().collect(Collectors.groupingBy(w -> w.getUserId()));
Run Code Online (Sandbox Code Playgroud)
Sonar Lint给了我以下错误:
用方法引用替换此lambda.
->
我尝试过的:
基于这些问题:SONAR:用方法引用和Runable接口替换此lambda:用方法引用替换此lambda.(sonar.java.source未设置.假设为8或更高.)
filterErrors.stream().collect(Collectors.groupingBy(this::getUserId()));
Run Code Online (Sandbox Code Playgroud)
基于这个问题:用方法引用'Objects :: nonNull'替换这个lambda
filterErrors.stream().collect(Collectors.groupingBy(UUID::getUserId()));
Run Code Online (Sandbox Code Playgroud)
两者都给出错误:
此表达式的目标类型必须是功能接口
有没有办法解决这个SonarLint问题?
javascript ×4
vue.js ×4
java ×3
dayofweek ×1
java-time ×1
lambda ×1
locale ×1
performance ×1
sonarlint ×1
vuejs2 ×1