国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

《代碼實例前端》Vue-cil腳手架,二級路由,增刪查改

這篇具有很好參考價值的文章主要介紹了《代碼實例前端》Vue-cil腳手架,二級路由,增刪查改。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

《代碼實例前端》Vue-cil腳手架,二級路由,增刪查改

《代碼實例前端》Vue-cil腳手架,二級路由,增刪查改

《代碼實例前端》Vue-cil腳手架,二級路由,增刪查改

UserAdd.vue

<template>
  <div>
     <!--div的class 為error是驗證錯誤,ok是驗證成功-->
             <div>
                <label for="userCode">用戶編碼:</label>
                <input type="text"  v-model="user.code" name="userCode" id="userCode" value="">
                <!-- 放置提示信息 -->
                <font color="red"></font>
            </div>
            <div>
                <label for="userName">用戶名稱:</label>
                <input type="text" name="userName" v-model="user.username"  id="userName" value="">
                <font color="red"></font>
            </div>
            <div>
                <label for="userAccount">賬號名稱:</label>
                <input type="text" name="userAccount" v-model="user.account"  id="userAccount" value="">
                <font color="red"></font>
            </div>
            <div>
                <label for="userPassword">用戶密碼:</label>
                <input type="password" v-model="user.password" name="userPassword" id="userPassword" value="">
                <font color="red"></font>
            </div>         
            <div >
                <input type="button" value="保存" @click="saveUser">
                <input type="button" id="back" name="back" value="返回">
            </div>
  </div>
</template>

<script>
export default {
  data(){
    return{
      user:{
            code:'',
            username:'',
            password:'',
            account:''
                   
            }
    }
  },
  methods:{
    saveUser(){
                console.log(this.user);
                const jwt=localStorage.getItem("jwt");
                this.$axios.post('api/user/addUser',this.user,{headers:{'jwt':jwt}})
                .then(res=>{
                    console.log(res.data)
                    if(res.data.code==5000){
                        alert("沒有操作權(quán)限!!!")
                    }
                    if(res.data.code==200){
                      this.$router.push({name:'userList'})
                    }
                })
            }
  }

}
</script>

<style scoped>

</style>

UserList.vue

<template>
  <div class="userlist">
    <p>姓名:<input type="text" v-model="name"/><button>查詢</button><router-link to="/userAdd" tag="button">新增</router-link></p>
    <table align="center" border="1px" cellpadding="10">
        <th>序號</th>
        <th>姓名</th>
        <th>年齡</th>
        <th>性別</th>
        <th>籍貫</th>
        <th>操作</th>
        <tr v-for="u in userList" :key="u.id">
            <td>{{u.id}}</td>
            <td>{{u.username}}</td>
            <td>14</td>
            <td>{{u.gender==1?'男':'女'}}</td>
            <td>江蘇</td>
            <td><router-link to="/userAdd" tag="button">新增</router-link></td>
            <td><input type="button" value="刪除" @click="removeUser(u.id)"></td>
            <td><button @click="updateUser(u.id)">修改</button></td>            
        </tr>
    </table>
  </div>
</template>

<script>
export default {
    data(){
        return{
            userList:[],
            name:''
        }
    },
    methods:{
        
        queryUser(){
            let jwt=localStorage.getItem("jwt")
            this.$axios.get('api/user/queryUser?name='+this.name+"&gender=0",{headers:{'jwt':jwt}})
            .then(res=>{
                console.log(res.data);
                if(res.data.code==200){
                    this.userList=res.data.data
                }
            })
        },
        removeUser(id){
                
                const jwt=localStorage.getItem("jwt");
                this.$axios.get('api/user/removeUser?id='+id,{headers:{'jwt':jwt}})
                .then(res=>{
                    console.log(res.data)
                    if(res.data.code==5000){
                        alert("沒有操作權(quán)限!!!")
                    }
                    if(res.data.code==200){
                        this.queryUser();
                    }
                })
            },
        updateUser(id){
            //路由帶參數(shù)
            //如果你想通過name跳轉(zhuǎn)路由,帶參,可以用params或者query
            //如果你想通過path跳轉(zhuǎn)路由,只能用query方式帶
             this.$router.push({name:'userUpdate',params:{"id":id}})
             //this.$router.push({path:'/userUpdate',query:{"id":id}})
        }

    },
    created(){
        this.queryUser();
    }

}
</script>

<style scoped>
.userlist{
    margin: 0 auto;
    text-align: center;
}

</style>

UserManagement.vue

<template>
  <div>
    <router-view></router-view>
  </div>
</template>

<script>
export default {

}
</script>

<style scoped>

</style>

UserUpdate.vue

<template>
  <div>
     <!--div的class 為error是驗證錯誤,ok是驗證成功-->
          
            <div>
                <label for="userName">用戶名稱:</label>
                <input type="text" name="userName" v-model="user.username"  id="userName" value="">
                <font color="red"></font>
            </div>
            <div>
                <label for="userAccount">賬號名稱:</label>
                <input type="text" name="userAccount" v-model="user.account"  id="userAccount" value="">
                <font color="red"></font>
            </div>
            <div>
                <label for="userPassword">用戶密碼:</label>
                <input type="password" v-model="user.password" name="userPassword" id="userPassword" value="">
                <font color="red"></font>
            </div>         
            <div >
                <input type="button" value="保存" @click="updateUser">
                <input type="button" id="back" name="back" value="返回">
            </div>
  </div>
</template>

<script>
export default {
  data(){
    return{
      user:{
            id:'',
            username:'',
            password:'',
            account:'',
            sex:1,
            phone:''      
            }
    }
  },
  methods:{
    updateUser(){
                console.log(this.user);
                const jwt=localStorage.getItem("jwt");
                this.$axios.post('api/user/updateUser',this.user,{headers:{'jwt':jwt}})
                .then(res=>{
                    console.log(res.data)
                    if(res.data.code==5000){
                        alert("沒有操作權(quán)限!!!")
                    }
                    if(res.data.code==200){
                        this.$router.push({name:'userList'})
                    }
                })
            }
  },
  created(){
    console.log(this.$route.params.id)
        this.user.id=this.$route.params.id
        const jwt=localStorage.getItem("jwt");
        this.$axios.get('api/user/findId?id='+this.user.id,{headers:{'jwt':jwt}})
        .then(res=>{
                    console.log(res.data)
                    if(res.data.code==5000){
                        alert("沒有操作權(quán)限!!!")
                    }
                    if(res.data.code==200){                       
                      this.user=res.data.data
                    }
                })
    }

}
</script>

<style scoped>

</style>

Action.vue

<template>
  <div>
    <table>
        <th>電影名</th>
        <tr>
            <td>戰(zhàn)狼3</td>
            <td>殺破狼</td>
        </tr>
    </table>
  </div>
</template>

<script>
export default {

}
</script>

<style scoped>

</style>

Comedy.vue

<template>
    <div>
      <table>
          <th>電影名</th>
          <tr>
              <td>夏洛特?zé)?span id="n5n3t3z"    class="token tag"></td>
              <td>逐夢演藝圈</td>
          </tr>
      </table>
    </div>
  </template>
  
  <script>
  export default {
  
  }
  </script>
  
  <style scoped>
  
  </style>

HelloWorld.vue

<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <p>
      For a guide and recipes on how to configure / customize this project,<br>
      check out the
      <a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
    </p>
    <h3>Installed CLI Plugins</h3>
    <ul>
      <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
      <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router" target="_blank" rel="noopener">router</a></li>
    </ul>
    <h3>Essential Links</h3>
    <ul>
      <li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
      <li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
      <li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
      <li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
      <li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
    </ul>
    <h3>Ecosystem</h3>
    <ul>
      <li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
      <li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
      <li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
      <li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
      <li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  props: {
    msg: String
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>

Movie.vue

<template>
  <div>
    <router-link to="/action1">動作</router-link>|
    <router-link to="/comedy1">喜劇</router-link>

    <router-view></router-view>
  </div>
</template>

<script>
export default {

}
</script>

<style scoped>

</style>

MyRouter.vue

<template>
  <div>
    <h3>myrouter</h3>

  </div>
</template>

<script>
export default {

}
</script>

<style scoped>

</style>

index.js

import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

const about= () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
const myrouter =()=> import('../components/MyRouter.vue')
const movie =()=> import('../components/Movie.vue')
const action =()=> import('../components/Action.vue')
const comedy =()=> import('../components/Comedy.vue')
const userIndex=()=>import('../components/user/UserManagement.vue')
const userList=()=>import('../components/user/UserList.vue')
const userAdd=()=>import('../components/user/UserAdd.vue')
const userUpdate=()=>import('../components/user/UserUpdate.vue')

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView
  },
  {
    path: '/about',
    name: 'about',
    //懶加載方式導(dǎo)入
    component:about
  },
  {
    path:'/path',
    name:'my',
    //懶加載
    component:myrouter
  },
  {
    path:'/movie',
    name:'movie',
    //懶加載
    component:movie,
    children:[
      //設(shè)置二級默認(rèn)路由
      {path:'/',redirect:'/action1'},
      {path:'/action1',name:'action',component:action},
      {path:'/comedy1',name:'comedy',component:comedy}
    ]
  },
  {
    path:'/userIndex',name:'userIndex',component:userIndex,
    children:[
      {path:'/',redirect:'/userList'},
      {path:'/userList',name:'userList',component:userList},
      {path:'/userAdd',name:'usreAdd',component:userAdd},
      {path:'/userUpdate',name:'userUpdate',component:userUpdate},
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router

AboutView.vue

<template>
  <div class="about">
    <h1>This is an about page</h1>
  </div>
</template>

HomeView.vue

<template>
  <div class="login">

  <form action="">
      <p>賬號<input type="text" v-model="username"></p>
      <p>密碼<input type="password" v-model="password"></p>
      <p><input type="button" value="登錄" @click="loginBtn"></p>
  </form>
  
  </div>
</template>

<script>


export default {
  data(){
    return{
      username:'',
      password:''
    }
  },



 methods:{
  loginBtn(){

    let param= new URLSearchParams();
    param.append("username",this.username);
    param.append("password",this.password);

    this.$axios({
      url:'api/login',
      method:'post',
      data:param
    }).then(res=>{
      console.log(res.data);
      if(res.data.code==200){
          localStorage.setItem("jwt",res.data.data);
         //路由跳轉(zhuǎn)
        //第一種通過name跳轉(zhuǎn)
        //this.$router.push("userList")
        //第二種通過path跳轉(zhuǎn)
        this.$router.push({path:'/userList'})
        
      }
    })


   

  }
 }
}
</script>

<style scoped>
.login{
  border: 1px solid green;
  width: 20%;
  margin: 0 auto;
  text-align: center;
  margin-top: 10%;
}
</style>

App.vue

<template>
  <div id="app">
   <nav>
    <router-link to="/movie">電影</router-link>
   </nav>
    <router-view/>
  </div>
</template>

<style>

</style>

main.js

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from 'axios'
Vue.prototype.$axios = axios


Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')

vue.config.js文章來源地址http://www.zghlxwxcb.cn/news/detail-402982.html

const { defineConfig } = require('@vue/cli-service')
module.exports = {
  transpileDependencies: true,
  devServer: {
  port: 8888,  //vue項目訪問端口
    proxy: {
      "/api": { // 1
        target: 'http://127.0.0.1:8082',   // 2
        changeOrigin: true, // 3
        pathRewrite: {
          '^/api': '/' // 4
        }
      }
    }
  }
}

到了這里,關(guān)于《代碼實例前端》Vue-cil腳手架,二級路由,增刪查改的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Vue(Vue腳手架)

    Vue(Vue腳手架)

    Vue官方提供腳手架平臺選擇最新版本: 可以相加兼容的標(biāo)準(zhǔn)化開發(fā)工具(開發(fā)平臺) 禁止:最新的開發(fā)技術(shù)版本和比較舊版本的開發(fā)平臺 ? Vue CLI ??? Vue.js 開發(fā)的標(biāo)準(zhǔn)工具 https://cli.vuejs.org/zh/ c:cmmand l:line i:interface 命令行接口工具? ?在cmd中查看vue是否存在cli ?全局安

    2024年02月01日
    瀏覽(20)
  • 前端如何搭建腳手架并在本地運(yùn)行

    前端如何搭建腳手架并在本地運(yùn)行

    在開始搭建前,確保本機(jī)安裝了node,為避免奇奇怪怪的問題 建議node版本16以上 使用過vue ,react,angular的同學(xué)都知道 ,應(yīng)該對腳手架有一定的理解,比如vue-cli的 vue create myApp ,其中vue 就是vue-cli聲明的一個命令,下來我們創(chuàng)建一個項目并聲明自己的命令。 創(chuàng)建一個空的文件夾

    2024年02月20日
    瀏覽(30)
  • 使用Vue腳手架

    使用Vue腳手架

    (193條消息) 第 3 章 使用 Vue 腳手架_qq_40832034的博客-CSDN博客 說明 1.Vue腳手架是Vue官方提供的標(biāo)準(zhǔn)化開發(fā)工具(開發(fā)平臺) 2.最新的版本是4.x 3.文檔Vue CLI腳手架(命令行接口) 具體步驟 1.如果下載緩慢請配置npm淘寶鏡像 npm config set registry http://registry.npm.taobao.org 2.全局安裝 @v

    2024年02月13日
    瀏覽(35)
  • Vue 腳手架

    ├── node_modules ├── public │ ├── favicon.ico: 頁簽圖標(biāo) │ └── index.html: 主頁面 ├── src │ ├── assets: 存放靜態(tài)資源 │ │ └── logo.png │ │── component: 存放組件 │ │ └── HelloWorld.vue │ │── App.vue: 匯總所有組件 │ │── main.js: 入口文件 ├── .gi

    2024年03月24日
    瀏覽(19)
  • 前端架構(gòu): 腳手架框架之yargs高級應(yīng)用教程

    腳手架框架之yargs高級應(yīng)用 1 )高級應(yīng)用概述 現(xiàn)在還用 xyzcli 這個腳手架,繼續(xù)在這個項目中來看yargs的高級用法 在 yargs 文檔中, 給出了復(fù)雜應(yīng)用的方式,這里做下詳解 https://www.npmjs.com/package/yargs?activeTab=readme#complex-example 這里主要關(guān)注 ↓ command recommendCommands fail 2 )command 應(yīng)用

    2024年02月20日
    瀏覽(26)
  • vue腳手架文件說明

    vue腳手架文件說明

    node_modules 都是下載的第三方包 public/index.html 瀏覽器運(yùn)行的網(wǎng)頁 src/main.js webpack打包的入口 src/APP.vue Vue頁面入口 package.json 依賴包列表文件

    2024年02月15日
    瀏覽(33)
  • Vue腳手架搭建項目

    Vue腳手架搭建項目

    一、 安裝Node.js (一) 注意事項 1. 注意電腦系統(tǒng)版本以及位數(shù),按照自己電腦的環(huán)境下載相應(yīng)的Node.js安裝包 2. 確定運(yùn)行項目的Node.js版本和npm版本,避免后期因為版本不同而產(chǎn)生的一些差異問題 3. 在官網(wǎng)下載Node安裝包時請下載穩(wěn)定版(或不同版本的穩(wěn)定版),正確區(qū)分穩(wěn)定版

    2024年02月09日
    瀏覽(37)
  • 如何搭建vue腳手架

    使用 create-vue 腳手架創(chuàng)建項目 create-vue參考地址:GitHub - vuejs/create-vue: ??? The recommended way to start a Vite-powered Vue project 步驟: 執(zhí)行創(chuàng)建命令 2.選擇項目依賴類容 安裝:項目開發(fā)需要的一些插件 必裝: Vue Language Features (Volar) ?vue3語法支持 TypeScript Vue Plugin (Volar) ?vue3中更好的

    2023年04月14日
    瀏覽(26)
  • vue腳手架創(chuàng)建項目

    vue腳手架創(chuàng)建項目

    npm install -g @vue/cli 如果報錯可以嘗試使用cnpm vue -V vue create 項目名稱 輸入y 上下選中選項 Manually select features (自由選擇),回車 vue 版本的選擇 其他按需要選擇

    2024年02月05日
    瀏覽(30)
  • 使用Vue腳手架2

    使用Vue腳手架2

    ref屬性 src/components/SchoolName.vue ? src/App.vue ? props配置項 src/App.vue src/components/StudentName.vue ? 注意:當(dāng)props中與當(dāng)前組件配置同名時, props中的配置優(yōu)先級高于當(dāng)前組件? mixin混入 1. 組件和混入對象含有同名選項 時,這些選項將以恰當(dāng)?shù)姆绞竭M(jìn)行“合并”,在發(fā)生沖突時以 組件

    2024年02月12日
    瀏覽(18)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包