Skip to content

Commit

Permalink
fix(element): fix vuepress doc not identify fetch (#1769)
Browse files Browse the repository at this point in the history
  • Loading branch information
muuyao authored Jul 12, 2021
1 parent 15065a7 commit bc4348e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
23 changes: 13 additions & 10 deletions packages/element/docs/demos/guide/cascader/base.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { createForm } from '@formily/core'
import { createSchemaField } from '@formily/vue'
import { Form, FormItem, Cascader, Submit } from '@formily/element'
import { action } from '@formily/reactive'
import axios from 'axios'
const transformAddress = (data = {}) => {
return Object.entries(data).reduce((buf, [key, value]) => {
Expand All @@ -36,16 +37,18 @@ const transformAddress = (data = {}) => {
}, [])
}
const useAsyncDataSource = (url, transform) => (field) => {
field.loading = true
fetch(url)
.then((res) => res.json())
.then(
action((data) => {
field.dataSource = transform(data)
field.loading = false
})
)
const useAsyncDataSource = (url, transform) => {
return (field) => {
field.loading = true
axios.get(url)
.then((res) => res.data)
.then(
action((data) => {
field.dataSource = transform(data)
field.loading = false
})
)
}
}
const schema = {
Expand Down
3 changes: 2 additions & 1 deletion packages/element/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"sass": "^1.34.1",
"vue": "^2.6.0",
"vuepress": "^1.8.2",
"vuepress-plugin-typescript": "^0.3.1"
"vuepress-plugin-typescript": "^0.3.1",
"axios": "^0.21.1"
},
"dependencies": {
"@formily/core": "2.0.0-beta.76",
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4440,6 +4440,13 @@ aws4@^1.8.0:
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59"
integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==

axios@^0.21.1:
version "0.21.1"
resolved "https://registry.nlark.com/axios/download/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8"
integrity sha1-IlY0gZYvTWvemnbVFu8OXTwJsrg=
dependencies:
follow-redirects "^1.10.0"

babel-core@^7.0.0-bridge.0:
version "7.0.0-bridge.0"
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece"
Expand Down Expand Up @@ -8212,7 +8219,7 @@ fn-name@~2.0.1:
resolved "https://registry.yarnpkg.com/fn-name/-/fn-name-2.0.1.tgz#5214d7537a4d06a4a301c0cc262feb84188002e7"
integrity sha1-UhTXU3pNBqSjAcDMJi/rhBiAAuc=

follow-redirects@^1.0.0:
follow-redirects@^1.0.0, follow-redirects@^1.10.0:
version "1.14.1"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.1.tgz#d9114ded0a1cfdd334e164e6662ad02bfd91ff43"
integrity sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg==
Expand Down

0 comments on commit bc4348e

Please sign in to comment.