我试图在 vuejs 中拥有一个与 es6 类关联的计算属性。我的 Vue 实例如下所示:
...
props: ['customClass'],
computed: {
localClass: {
get() {
return this.customClass
},
set (value) {
console.log("changed")
}
}
}
...
Run Code Online (Sandbox Code Playgroud)
我的班级看起来像这样
class CustomClass {
constructor () {
this.selected = false
}
}
Run Code Online (Sandbox Code Playgroud)
如果我尝试做这样的事情:
this.localClass.selected = true
Run Code Online (Sandbox Code Playgroud)
但是从来没有调用过二传手,就像反应性已经丢失一样,我不明白为什么。
我也尝试:
Vue.set(this.localClass, 'selected', true)
Run Code Online (Sandbox Code Playgroud)
我将 customClass 作为 prop 传递,但即使直接在组件中创建新实例也不会改变结果。
在 vuejs 文档中,我不记得有一节讨论过 es6 类中的反应性问题,所以我想知道是否有人知道为什么以及如何使我的类具有反应性。
提前致谢
有谁知道如何在循环中插入命名槽?例如,我有这个代码:儿童
<div v-for="num in nums" :key="num">
<slot name="foo"></slot>
</div>
Run Code Online (Sandbox Code Playgroud)
而父母是这样的:
<foo-component :nums="nums>
<template slot="foo">
<span>Inside the foo component</span>
</template>
</foo-component>
Run Code Online (Sandbox Code Playgroud)
如果我这样做,控制台将显示此警报:
Duplicate presence of slot "foo" found in the same render tree - this will likely cause render errors.
Run Code Online (Sandbox Code Playgroud)
有谁知道如何做到这一点?
提前致谢
我正在尝试使用 PLSQL 存储过程获取行,并将它们保存到 JPA 实体中。我正在使用ojbdc7,spring-boot-starter-data-jpa和spring-boot 2.2.1.
这是我的程序:
create or replace PACKAGE BODY pkg_test
AS
PROCEDURE getAll(res OUT SYS_REFCURSOR)
IS
BEGIN
OPEN res FOR SELECT * FROM employee;
END getAll;
END pkg_test;
Run Code Online (Sandbox Code Playgroud)
我的实体是:
package com.stefanocapra.plsql.entities;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedStoredProcedureQueries;
import javax.persistence.NamedStoredProcedureQuery;
import javax.persistence.ParameterMode;
import javax.persistence.StoredProcedureParameter;
import antlr.collections.List;
@Entity
@NamedStoredProcedureQueries({
@NamedStoredProcedureQuery(
name = "getAll",
procedureName = "pkg_test.getAll",
resultClasses = Employee.class,
parameters = {
@StoredProcedureParameter(mode = ParameterMode.REF_CURSOR, type = void.class)
})
})
public …Run Code Online (Sandbox Code Playgroud) vue.js ×2
ecmascript-6 ×1
es6-class ×1
java ×1
javascript ×1
loops ×1
plsql ×1
slot ×1
spring ×1