vite

Vite官网)

npm create vite@latest

yarn create vite

VUE3

我tm!

原来

data()
methods()
mounted()

现在

<script setup>
import { onMounted, reactive, ref } from 'vue'
import axios from 'axios'
const selectedKeys = ref(['1'])//简单对象
const menu = reactive(//复杂对象
  [
    {
      title: '数据分析',
      route: '/data-analysis'
    },
    {
      title: '修改商品',
      route: '/modify-goods'
    },

  ]
)
// mounted
onMounted(() => {
  axios({
    url: '/user/login',
    method: 'post',
  }).then(res => {
    console.log(res)
    menu.push({
      title: '修改权限',
      route: '/modify-permission'
    })
  })
})



</script>

插件

自动导入插件

npm i unplugin-vue-components -D 再根据各个ui框架另外配置

Last updated