-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from fyl080801/dev
Dev
- Loading branch information
Showing
35 changed files
with
3,310 additions
and
1,497 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# 按条件显示 | ||
|
||
## 使用转换的结果作为条件 | ||
|
||
组件定义一个 `condition` 属性,可以写固定值,也可以使用转换来决定值,当这个值为真的时候组件被显示 | ||
|
||
::: demo | ||
|
||
```html | ||
<template> | ||
<div> | ||
<vjform v-model="model" :fields="fields" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
model: { | ||
show: false | ||
}, | ||
fields: [ | ||
{ | ||
component: "el-checkbox", | ||
model: ["show"], | ||
children: [{ component: "span", text: "是否显示" }] | ||
}, | ||
{ | ||
component: "p", | ||
condition: { $type: "bind", $source: "model.show" }, | ||
text: "显示的内容..." | ||
} | ||
] | ||
}; | ||
} | ||
}; | ||
</script> | ||
``` | ||
|
||
::: | ||
|
||
## 使用 json-schema 验证作为条件 | ||
|
||
定义一个`displayOptions`属性,包含 `model` 和 `schema` | ||
|
||
`model` 是组件的 `model` 里的某个属性,支持路径,`schema` 是这个属性 json-schema 验证条件,当指定 `model` 的属性值符合 `schema` 里的验证条件,可显示组件 | ||
|
||
::: demo | ||
|
||
```html | ||
<template> | ||
<div> | ||
<vjform v-model="model" :fields="fields" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
model: { | ||
show: false | ||
}, | ||
fields: [ | ||
{ | ||
component: "el-checkbox", | ||
model: ["show"], | ||
children: [{ component: "span", text: "是否显示" }] | ||
}, | ||
{ | ||
component: "p", | ||
displayOptions: { | ||
model: "show", | ||
schema: { | ||
type: "boolean", | ||
const: true | ||
} | ||
}, | ||
text: "显示的内容..." | ||
} | ||
] | ||
}; | ||
} | ||
}; | ||
</script> | ||
``` | ||
|
||
::: |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { getMapDeault } from "../utils"; | ||
import { getMapDefault } from "../utils/helpers"; | ||
|
||
const store = new Map(); | ||
|
||
export const getFeature = type => { | ||
return getMapDeault(store, type, new Map()); | ||
return getMapDefault(store, type, new Map()); | ||
}; | ||
|
||
export default store; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
import feature from "../../feature"; | ||
|
||
feature("datasource")("object", function(getOptions) { | ||
const options = getOptions(); | ||
feature | ||
.datasource("object", function(getOptions) { | ||
const options = getOptions(); | ||
|
||
const instance = { | ||
watchs: [], | ||
data: options.data // 这里只能关联options的data,因为data的转换表达式最终转换到options的对象里 | ||
}; | ||
const instance = { | ||
watchs: [], | ||
data: options.data // 这里只能关联options的data,因为data的转换表达式最终转换到options的对象里 | ||
}; | ||
|
||
instance.watchs.push( | ||
this.$watch( | ||
() => options.data, | ||
value => { | ||
instance.data = value; | ||
}, | ||
{ deep: true } | ||
) | ||
); | ||
instance.watchs.push( | ||
this.$watch( | ||
() => options.data, | ||
value => { | ||
instance.data = value; | ||
}, | ||
{ deep: true } | ||
) | ||
); | ||
|
||
return instance; | ||
}).withName("对象"); | ||
return instance; | ||
}) | ||
.withName("对象"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.