当前位置: 首页 > news >正文

Vue3.0极速入门- 目录和文件说明

目录结构

以下文件均为npm create helloworld自动生成的文件目录结构

目录截图

目录说明

目录/文件说明
node_modulesnpm 加载的项目依赖模块
src这里是我们要开发的目录,基本上要做的事情都在这个目录里
assets放置一些图片,如logo等。
componentsvue组件文件的存放目录,也是主要的工作目录
App.vue项目入口文件,我们也可以直接将组件写这里,而不使用 components 目录。
main.js项目的核心文件。
index.html首页入口文件,你可以添加一些 meta 信息或统计代码啥的。
package.json项目配置文件。
README.md项目的说明文档,markdown 格式

文件说明

index.html:启动页面

<div id="app">为后续的vue文件提供可替换的壳标签

<!DOCTYPE html>
<html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1.0"><link rel="icon" href="<%= BASE_URL %>favicon.ico"><title><%= htmlWebpackPlugin.options.title %></title></head><body><noscript><strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><!-- built files will be auto injected --></body>
</html>

main.js:入口文件,类似于java的main方法

功能有两个:

1、导入vue框架;
2、将App.vue的内容挂载(替换)到index.html的<div id="app"/>标签

import { createApp } from 'vue'
import App from './App.vue'createApp(App).mount('#app')

App.vue:第一个vue文件

<!-- 一、Vue的文件结构为三段式1.template负责页面元素搭建2.script负责js代码3.style负责css样式二、使用其他的vue组件分两步1.导入:1.1在js方法中import组件1.2在export default中使用components注册组件2.使用:在template中使用组件标签
-->
<template><img alt="Vue logo" src="./assets/logo.png"><HelloWorld msg="Welcome to Your Vue.js App"/>  <!-- 在template中使用组件标签 -->
</template><script>
import HelloWorld from './components/HelloWorld.vue' // 在js方法中import组件export default {name: 'App',components: {HelloWorld        // 在export default中使用components注册组件}
}
</script><style>
#app {font-family: Avenir, Helvetica, Arial, sans-serif;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;text-align: center;color: #2c3e50;margin-top: 60px;
}
</style>

HelloWorld.vue: 展示页面

msg是定义好的参数,外部组件(App.vue)可以通过参数传递的方式,将数据传给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></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>

 

http://www.lryc.cn/news/140828.html

相关文章:

  • RabbitMQ---订阅模型-Direct
  • Django REST framework实现api接口
  • 4.19 20
  • (动态规划) 剑指 Offer 10- II. 青蛙跳台阶问题 ——【Leetcode每日一题】
  • 物联网WIFI 模块AT指令版本七大元凶
  • Qt 正则(数据格式校验、替换指定格式数据、获取匹配数据)
  • 网络层协议——ip
  • Qt6和Rust结合构建桌面应用
  • Kubernetes(K8S)简介
  • 面试中问:React中函数组件和class组件的区别,hooks模拟生命周期
  • Python高光谱遥感数据处理与高光谱遥感机器学习方法应用
  • Java实现接收xml格式数据并解析,返回xml格式数据
  • 【C++】初步认识模板
  • Ansible 临时命令搭建安装仓库
  • phpstorm动态调试
  • 二叉树的层序遍历及完全二叉树的判断
  • java八股文面试[JVM]——JVM内存结构
  • Kafka基本使用
  • 【目标检测】理论篇(2)YOLOv3网络构架及其代码实现
  • k8s之工作负载、Deployment、DaemonSet、StatefulSet、Job、CronJob及GC
  • IDEA项目实践——Element UI概述
  • Docker 容器学习笔记
  • Day03-vue基础
  • RAC sid=‘*‘ 最好加上 v$system_parameter
  • 【位运算进阶之----左移(<<)】
  • 石油石化行业网络监控运维方案,全局态势感知,实时预警
  • MyBatis 的关联关系配置 一对多,一对一,多对多 关系的映射处理
  • Diffusion Models for Image Restoration and Enhancement – A Comprehensive Survey
  • Springboot开发所遇问题(持续更新)
  • 智能电视与win10电脑后续无法实现DLNA屏幕共享