(0 , _stores_token_js__WEBPACK_IMPORTED_MODULE_3__.useTokenStore) is not a f

简介: (0 , _stores_token_js__WEBPACK_IMPORTED_MODULE_3__.useTokenStore) is not a f

(0 , _stores_token_js__WEBPACK_IMPORTED_MODULE_3__.useTokenStore) is not a function TypeError: (0 , _stores_token_js__WEBPACK_IMPORTED_MODULE_3__.useTokenStore) is not a function at setup (webpack-internal:///./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/testLogin.vue?vue&type=script&setup=true&lang=js:24:82) at callWithErrorHandling (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:326:18) at setupStatefulComponent (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:6706:25) at setupComponent (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:6667:36) at mountComponent (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:5220:7) at processComponent (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:5198:9) at patch (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:4873:11) at ReactiveEffect.componentUpdateFn [as fn] (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:5397:9) at ReactiveEffect.run (webpack-internal:///./node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js:216:19) at instance.update (webpack-internal:///./node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js:5428:16)

意思是:useTokenStore不是函数

(0,_ stores _ token _ js _ _ web pack _ IMPORTED _ MODULE _ 3 _ _)。useTokenStore)不是函数 类型错误:(0,_ stores _ token _ js _ _ web pack _ IMPORTED _ MODULE _ 3 _ _。useTokenStore)不是函数 安装时(webpack-internal:///)。/node _ modules/babel-loader/lib/index . js??clonedRuleSet-40 . use【0】!。/node _ modules/vue-loader/dist/index . js??规则集【0】。使用【0】!。/src/views/testLogin.vue?vue & type = script & setup = true & lang = js:24:82) at callWithErrorHandling(web pack-internal:///)。/node _ modules/@ vue/runtime-core/dist/runtime-core . ESM-bundler . js:326:18) 位于setupStatefulComponent(web pack-internal:///)。/node _ modules/@ vue/runtime-core/dist/runtime-core . ESM-bundler . js:6706:25) at setup component(web pack-internal:///)。/node _ modules/@ vue/runtime-core/dist/runtime-core . ESM-bundler . js:6667:36) 安装组件时(webpack-internal:///。/node _ modules/@ vue/runtime-core/dist/runtime-core . ESM-bundler . js:5220:7) at process component(web pack-internal:///。/node _ modules/@ vue/runtime-core/dist/runtime-core . ESM-bundler . js:5198:9) 安装补丁(webpack-internal:///)。/node _ modules/@ vue/runtime-core/dist/runtime-core . ESM-bundler . js:4873:11) at react ive effect . component updatefn【as fn】(web pack-internal:///。/node _ modules/@ vue/runtime-core/dist/runtime-core . ESM-bundler . js:5397:9) at react ive effect . run(web pack-internal:///)。/node _ modules/@ vue/reactivity/dist/reactivity . ESM-bundler . js:216:19) at instance . update(web pack-internal:///)。/node _ modules/@ vue/runtime-core/dist/runtime-core . ESM-bundler . js:5428:16)

控制台也出现了这个函数不是函数的意思

main.js的配置

import { createApp } from 'vue'
import { QuillEditor } from '@vueup/vue-quill'
import '@vueup/vue-quill/dist/vue-quill.snow.css';
import App from './App.vue'
import router from '@/router'
import { createPinia } from 'pinia'
import { createPersistedState } from 'pinia-persistedstate-plugin'
// import editor from '@/views/editorViewDemo.vue'
// main.ts
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import locale from 'element-plus/theme-chalk/index.css'
const app = createApp(App);
const pinia = createPinia();
const persist = createPersistedState();
pinia.use(persist)
app.use(pinia)
 
// require styles
// const app = createApp(App)
// app.component('editorView', editor)
 
// app.component('QuillEditor', editor)
// 这个地方可能出问题
createApp(App).component('QuillEditor', QuillEditor).use(router).use(scroll).use(ElementPlus, { locale }).mount('#app')

token.js的配置

//定义store
import { defineStore } from 'pinia'
import { ref } from 'vue'
/* 
    第一个参数:名字,唯一性
    第二个参数:函数,函数的内部可以定义状态的所有内容
 
    返回值: 函数
*/
export const useTokenStore = defineStore('token', () => {
    //定义状态的内容
 
    //1.响应式变量
    const token = ref('')
 
    //2.定义一个函数,修改token的值
    const setToken = (newToken) => {
        token.value = newToken
    }
 
    //3.函数,移除token的值
    const removeToken = () => {
        token.value = ''
    }
 
    return {
        token, setToken, removeToken
    }
}, {
    persist: true//持久化存储
});

testLogin导入的配置

<script setup>
import { ref } from 'vue'
//调用后台接口,完成注册
import { userLoginService } from '@/api/user.js'
import { ElMessage } from "element-plus";
 
import router from '@/router';
import { useTokenStore } from '@/stores/token.js'
// const store = useTokenStore();
// const tokenStore = useTokenStore();
const tokenStore = useTokenStore();
const login = async () => {
 
    //registerData是一个响应式对象,如果要获取值,需要.value
    let result = await userLoginService(registerData.value);
    // if (result.code === 0) {
    //     //成功了
    //     alert(result.msg ? result.msg : '登录成功');
    // } else {
    //     //失败了
    //     alert('登录失败')
    // }
    ElMessage.success(result.data.msg ? result.data.msg : '登录成功')
    // store.setToken(result.data)
    tokenStore.setToken(result.data)
    router.push('/editor')
}
// 定义数据模型
const registerData = ref({
    username: '',
    password: '',
    rePassword: ''
})
 
 
</script>
<template>
    <el-row class="login-page">
        <el-col :span="12" class="bg"></el-col>
        <el-col :span="6" :offset="3" class="form">
            <!-- 注册表单 -->
            <el-form ref="form" size="large" autocomplete="off" :model="registerData">
                <el-form-item>
                    <h1>登录</h1>
                </el-form-item>
                <el-form-item prop="username">
                    <el-input placeholder="请输入用户名" v-model="registerData.username"></el-input>
                </el-form-item>
                <el-form-item prop="password">
                    <el-input type="password" placeholder="请输入密码" v-model="registerData.password"></el-input>
                </el-form-item>
                <!-- 注册按钮 -->
                <el-form-item>
                    <el-button class="button" type="primary" auto-insert-space @click="login">
                        登录
                    </el-button>
                </el-form-item>
            </el-form>
            <!-- 登录表单 -->
 
        </el-col>
    </el-row>
</template>
 
<script>
export default {
 
}
</script>
 
<style></style>

什么bug,哎莫名其妙好了

相关文章
|
4月前
|
JavaScript
Vue 开发中的一些问题简单记录,Cannot find module ‘webpack/lib/RuleSet‘
Vue 开发中的一些问题简单记录,Cannot find module ‘webpack/lib/RuleSet‘
243 1
|
4月前
|
JavaScript
文本,Pinia的使用,(0 , _stores_token_js__WEBPACK_IMPORTED_MODULE_1__.useTokenStore),接口中必须用引入store.js文件
文本,Pinia的使用,(0 , _stores_token_js__WEBPACK_IMPORTED_MODULE_1__.useTokenStore),接口中必须用引入store.js文件
|
6月前
|
前端开发 JavaScript
React 配置别名 @ ( js/ts 项目中通过 webpack.config.js 配置)
React 配置别名 @ ( js/ts 项目中通过 webpack.config.js 配置)
151 0
|
11月前
|
JavaScript
Error: Unsupported URL Type: npm:fork-ts-checker-webpack-plugin@^5.0.11
如果你去搜索,答案都是去升级你的npm 在StackOverflow说是vue3得在非vue-cli环境得单独配置。地址: 还有说npm install --save-dev fork-ts-checker-webpack-plugin 众说纷纭,都解决不了
115 0
webpack ---- 配置完成后的package.json与webpack.config.js & 使用@代替./ …/
webpack ---- 配置完成后的package.json与webpack.config.js & 使用@代替./ …/
|
JavaScript
UniApp 解决 Error: Cannot find module ‘webpack/lib/RuleSet‘
UniApp 解决 Error: Cannot find module ‘webpack/lib/RuleSet‘
938 0
|
负载均衡 监控 网络安全
pm2:ecosystem.config.js
pm2:ecosystem.config.js
331 0
|
JavaScript 前端开发
Webpack 中的 module、chunk、bundle 究竟是什么?
Webpack 中的 module、chunk、bundle 究竟是什么?
337 0
|
资源调度 开发工具 git
Cannot find module 'webpack'
Cannot find module 'webpack'
使用antd-theme-webpack-plugin报错Error LessError: Cannot find module ‘antd/lib/style/themes/default.less
使用antd-theme-webpack-plugin报错Error LessError: Cannot find module ‘antd/lib/style/themes/default.less
1100 0
使用antd-theme-webpack-plugin报错Error LessError: Cannot find module ‘antd/lib/style/themes/default.less