Vue.js 目录结构
项目创建成功后,用IDE打开,会有以下目录结构:
打开src目录中的App.vue文件,说明在注释中:
<!--展示模板-->
<template>
<div id="app">
<img src="./assets/logo.png">
<router-view></router-view>
</div>
</template>
<script>
// 导入组件
import Hello from './components/Hello'
export default {
name: 'app',
components: {
Hello
}
}
</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>接下来我们可以尝试修改初始化的项目,将 Hello.vue 修改为以下代码:
<template>
<div class="hello">
<h1>{{ msg }}</h1>
</div>
</template>
<script>
export default {
name: 'hello',
data () {
return {
msg: 'Welcome to w3h5.com'
}
}
}
</script>重新打开页面 http://localhost:8080/,修改后会自动刷新,显示效果如下所示:
![]()
未经允许不得转载:前端资源网 - w3h5 » Vue.js学习笔记——项目目录结构
前端资源网 - w3h5