从零开始学Vue3--环境搭建

1.搭建环境

下载nodejs

nodejs下载地址

更新npm

npm install -g npm

设置npm源,加快下载速度

npm config set registry https://registry.npmmirror.com

使用脚手架创建项目

npm create vue@latest

 根据你的需要选择对应选项

进入新建的项目下载依赖

npm install

 启动项目

npm run dev

 2.搭建测试页面

为了后续测试方便,我们在首页放置链接,一个链接一个测试页面

main.js去掉import './assets/main.css'

App.vue改成

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

<template>
  <RouterView />
</template>

<style scoped>
</style>

HomeView.vue改成

<template>
  <div>
    <a href="templateGrammar">模板语法</a>
  </div>
</template>
<style scoped>
a {
  text-decoration: none;
  color: hsla(160, 100%, 37%, 1);
  transition: 0.4s;
  padding: 10px;
}
</style>

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: '/templateGrammar',
      component: () => import('../views/TemplateGrammar.vue')
    }
  ]
})

export default router

在views下面新建一个TemplateGrammar.vue

<template>
<div>TemplateGrammar</div>
</template>

<script>
export default {
  name: "TemplateGrammar"
}
</script>

<style scoped>

</style>

如此基础的环境搭建好了,可以在上面一边测试一边学习了

  • 13
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值