-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
选择器加载异步数据token #84
Comments
自己重写 |
修改这个文件 src/plugins/formCreate/index.ts interface Option {
action: string
method?: AxiosMethod
data?: object
dataType?: object
headers?: object
withCredentials?: boolean
onSuccess: (body: any) => void
onError?: (e: Error | ProgressEvent) => void
_parse?: string
}
// 参考 http://www.form-create.com/v3/element-ui/auto-import.html 文档
export const setupFormCreate = (app: App<Element>) => {
components.forEach((component) => {
app.component(component.name, component)
})
formCreate.use(install)
const overrideFetch = (option: Option, effectArgs) => {
// console.log('--fetch option--', option)
serivice({
url: option.action,
method: option.method,
data: option.data,
headers: option.headers,
withCredentials: option.withCredentials
})
.then((res) => {
try {
if (option._parse) {
const parseFn = formCreate.parseFn(option._parse)
// console.log('--parseFn--', parseFn)
res.data = parseFn(res)
}
} catch (e) {
console.log('--parseFn error--', e)
}
option.onSuccess?.(res)
})
.catch((e) => {
option.onError?.(e)
})
return option
}
// 重写 fetch 请求方法,select 等动态获取数据请求通过拦截器
formCreate.fetch = overrideFetch
app.use(formCreate)
} |
请问下这个要怎么重写 |
@rujianwang 看一下楼上的代码, 核心就是 |
Vue.use(ELEMENT); formCreate.fetch = function(option, effectArgs) { 我在main.js里面这样写 默认不生效。我不太想 改你的源码 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fc-designer的选择器组件,在加载异步数据的时候怎么操作才能解决待token得问题???就是访问异步数据接口的时候能自带vue中的token??? 如: $store.user.token ,这种方式
The text was updated successfully, but these errors were encountered: