2.1创建Html文件 2.2通过!快捷键,快速创建html文件架构 2.3通过script标签引入Vue.js 2.3具体代码如下 <!DOCTYPE html> 2.4实验结果如图 (我直接从实验报告复制的,懒得下载到本地再上传了,各位自己调试八)
3.1安装手脚架并创建一个新的Vue项目 按照PPT输入两条命令,但注意的是在创建项目时选择Vue3
<template> <div> <h1>Login</h1> <form> <input type="text" v-model="username" placeholder="Username"> <input type="password" v-model="password" placeholder="Password"> <button @click="LoginComponent">Login</button> </form> </div> </template> L <script> export default { data() { return { username: '', password: '' }; }, methods: { login() { // 在这里可以编写登录逻辑 console.log('Username:', this.username); console.log('Password:', this.password); } } }; </script> <style scoped> h1 { text-align: center; } form { display: flex; flex-direction: column; align-items: center; margin-top: 20px; } input { margin-bottom: 10px; } button { padding: 10px 20px; } </style>
import { createApp } from 'vue' import App from './App.vue' import router from './router' createApp(App).use(router).mount('#app')
import { createRouter, createWebHistory } from 'vue-router' import LoginComponent from './LoginComponent' const routes = [ { path: '/', name: 'Login-compoment', component: LoginComponent } ] const router = createRouter({ history: createWebHistory(process.env.BASE_URL), routes }) export default router
<template> <div id="app"> <router-view></router-view> </div> </template> <style> #app { max-width: 400px; margin: 0 auto; padding: 20px; border: 1px solid #ccc; border-radius: 5px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); } </style>
|
河南大学web开发技术(vue)实验报告一
最新推荐文章于 2024-07-14 18:10:31 发布