vue脚手架build后的页面显示为空白

在脚手架的build文件夹中找到utils.js

utils.js

config里的index.js

index.js
应该大部分应该能解决

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用Vue脚手架编写登录页面的步骤: 1. 创建一个Vue项目并进入项目目录: ```shell vue create login-page cd login-page ``` 2. 安装Vue Router和Axios: ```shell npm install vue-router axios --save ``` 3. 在src目录下创建一个views目录,并在views目录下创建一个Login.vue文件,用于编写登录页面的代码: ```vue <template> <div> <h1>Login Page</h1> <form> <div> <label for="username">Username:</label> <input type="text" id="username" v-model="username"> </div> <div> <label for="password">Password:</label> <input type="password" id="password" v-model="password"> </div> <button type="submit" @click.prevent="login">Login</button> </form> </div> </template> <script> import axios from 'axios'; export default { data() { return { username: '', password: '' } }, methods: { login() { axios.post('/api/login', { username: this.username, password: this.password }) .then(response => { console.log(response.data); }) .catch(error => { console.log(error); }); } } } </script> ``` 4. 在src目录下创建一个router目录,并在router目录下创建一个index.js文件,用于配置路由: ```javascript import Vue from 'vue'; import VueRouter from 'vue-router'; import Login from '../views/Login.vue'; Vue.use(VueRouter); const routes = [ { path: '/', name: 'Login', component: Login } ]; const router = new VueRouter({ mode: 'history', base: process.env.BASE_URL, routes }); export default router; ``` 5. 在src目录下创建一个api目录,并在api目录下创建一个index.js文件,用于封装API请求: ```javascript import axios from 'axios'; const apiClient = axios.create({ baseURL: 'http://localhost:3000', withCredentials: true, headers: { Accept: 'application/json', 'Content-Type': 'application/json' } }); export default { login(credentials) { return apiClient.post('/api/login', credentials); } } ``` 6. 在src目录下的main.js文件中引入路由和API,并将其挂载到Vue实例上: ```javascript import Vue from 'vue'; import App from './App.vue'; import router from './router'; import api from './api'; Vue.config.productionTip = false; Vue.prototype.$api = api; new Vue({ router, render: h => h(App) }).$mount('#app'); ``` 7. 在src目录下的App.vue文件中添加路由占位符: ```vue <template> <div id="app"> <router-view/> </div> </template> <script> export default { name: 'App' } </script> ``` 8. 运行项目并访问登录页面: ```shell npm run serve ``` 以上是使用Vue脚手架编写登录页面的步骤,希望对你有所帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值