当前位置:   article > 正文

vue加载vuetify模板UI_vuetifyjs模板

vuetifyjs模板

step1:导入vuetify

yarn add vuetify
  • 1

step2: package.json数据 D:\vue_project\project-vue-json-main\package.json

  "dependencies": {
    "axios": "^1.6.8",
    "json-server": "^1.0.0-alpha.23",
    "vue": "^3.3.4",
    "vue-router": "^4.2.5",
    "vuetify": "^3.5.17"
  },
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

step3: main.js引入 D:\vue_project\project-vue-json-main\src\main.js

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import Axios from 'axios'
// Vuetify
import 'vuetify/styles'
import { createVuetify } from 'vuetify'
import * as components from 'vuetify/components'
import * as directives from 'vuetify/directives'

const vuetify = createVuetify({
    components,
    directives,
})

createApp(App)
    .use(Axios)
    .use(router)
    .use(vuetify)
    .mount('#app')


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

step4: router 导航 D:\vue_project\project-vue-json-main\src\App.vue

<script setup>
import { RouterLink, RouterView } from 'vue-router'
</script>

<template>
  <header>
    <nav>
      <RouterLink to="/">Home</RouterLink>
      <RouterLink to="/new">Create new</RouterLink>
    </nav>
  </header>
  <main>
    <RouterView />
  </main>
</template>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

step5: 导航管理类 D:\vue_project\project-vue-json-main\src\router\index.js

import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView
    },
    {
      path: "/new",
      name: "new document",
      component: () => import("../views/NewDocumentView.vue")
    }
  ]
})

export default router

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

step6: D:\vue_project\project-vue-json-main\src\views\HomeView.vue

<template>
  <div id="app">
    <v-btn @click="topPage">新增</v-btn>
    <v-btn @click="subPage">修改</v-btn>
    <v-btn @click="userListPage">删除</v-btn>
    <v-btn @click="userListPage">查询</v-btn>
  </div>
</template>

<script>
import Axios from 'axios'

export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  data() {
    return {
      list: []
    }
  },
  created(){
    this.fetch()
  },
  methods: {
    topPage() {
      const a = 3;
      const b = 5;
      const c = a + b;
      console.log("click test1"+c)
    },
    subPage() {
      this.createUser()
      console.log("click test2")
    },
    userListPage() {
      console.log("click test3")
    },
    createUser() {
      console.log("click test4")
    },
    fetch() {
      Axios.get("/clientes/1")
          .then(res => {
            this.list = res.data
            console.log(res)
          }).catch( err=> {
        console.log(err)
      })
    }
  }
}
</script>

<style>
</style>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58

end

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/753964
推荐阅读
相关标签
  

闽ICP备14008679号