在main.js
我有这样的事情:
import { myUtilFunc} from './helpers';
Object.defineProperty(Vue.prototype, '$myUtilFunc', { value: myUtilFunc });
Run Code Online (Sandbox Code Playgroud)
通过这种方式,我可以访问myUtilFunc
整个应用程序this.$myUtilFunc
但是,setup()
如果我无法访问 Vue 3中的方法,我该如何实现this
?
是否可以像在 Visual Studio Code 中一样通过 Vetur 在 Webstorm 中对 Vue 模板进行类型检查? 维图尔
如何使用 vuex-class 在 Vue 组件之外访问 Vuex?
在正常情况下,这非常简单:
// some JS file
import store from './../store'; // path to Vuex store
store.commit('ux/mutationName', somePayload)
Run Code Online (Sandbox Code Playgroud)
但我正在使用 vuex-class 并且我有 Vuex 模块:
import { Module } from 'vuex';
import { RootState } from '@/types/vuex/types';
import { MutationTree } from 'vuex';
import { GetterTree } from 'vuex';
const namespaced: boolean = true;
export interface UXState {
compLoading: boolean;
}
export const state: UXState = {
compLoading: false
};
export const mutations: MutationTree<UXState> = {
setCompLoading(state, payload: …
Run Code Online (Sandbox Code Playgroud) 请帮我弄清楚为什么浏览器(Chrome 和任何其他浏览器)不设置 cookie,而 Set-Cookie 标头出现在响应标头中:
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 345
Content-Type: application/json; charset=utf-8
Date: Sat, 18 Jan 2020 21:15:53 GMT
ETag: W/"159-UXuykOchcveuYBb7xZpN5Luf3jU"
Set-Cookie: jwt=************; Path=/; Expires=Fri, 17 Apr 2020 21:15:53 GMT; HttpOnly
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Content-Type-Options: nosniff
X-DNS-Prefetch-Control: off
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Run Code Online (Sandbox Code Playgroud)
我的应用程序运行在:http://localhost:8080