vue学习笔记(三): 启动说明
2024-10-09 12:01:42
1、启动页面:index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>hcmanage</title>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
其中 <div id="app"></div> 是用于挂载页面的
2、启动js: main.js
import Vue from 'vue' //引入vue.js
import App from './App' //引入App.vue
import router from './router' //引入router下的所有路由
import './plugins/element.js' //引入element-ui Vue.config.productionTip = false new Vue({
el: '#app',//要挂载的元素ID
router,
components: { App },//挂载App组件
template: '<App/>'
})
3、挂载的App.vue
<template>
<div id="app">
<img src="./assets/logo.png">
<div>
<p>
If Element is successfully added to this project, you'll see an
<code v-text="'<el-button>'"></code>
below
</p>
<el-button>el-button</el-button>
</div>
<!--下面JS脚本加载的HelloWorld组件 msg是HelloWorld中要使用的变量-->
<HelloWorld msg="Welcome to Your Vue.js App"/>
</div>
</template> <script>
import HelloWorld from './components/HelloWorld.vue' //引入HelloWorld.vue export default {
name: 'app',
components: {
HelloWorld
}
}
</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>
4、App.vue引入的HelloWorld.vue
<template>
<div class="hello">
<!--用于接收加载页面传入的信息-->
<h1>{{ msg }}</h1>
<h2>Essential Links</h2>
<ul>
<li>
<a
href="https://vuejs.org"
target="_blank"
>
Core Docs
</a>
</li>
<li>
<a
href="https://forum.vuejs.org"
target="_blank"
>
Forum
</a>
</li>
<li>
<a
href="https://chat.vuejs.org"
target="_blank"
>
Community Chat
</a>
</li>
<li>
<a
href="https://twitter.com/vuejs"
target="_blank"
>
</a>
</li>
<br>
<li>
<a
href="http://vuejs-templates.github.io/webpack/"
target="_blank"
>
Docs for This Template
</a>
</li>
</ul>
<h2>Ecosystem</h2>
<ul>
<li>
<a
href="http://router.vuejs.org/"
target="_blank"
>
vue-router
</a>
</li>
<li>
<a
href="http://vuex.vuejs.org/"
target="_blank"
>
vuex
</a>
</li>
<li>
<a
href="http://vue-loader.vuejs.org/"
target="_blank"
>
vue-loader
</a>
</li>
<li>
<a
href="https://github.com/vuejs/awesome-vue"
target="_blank"
>
awesome-vue
</a>
</li>
</ul>
</div>
</template> <script>
export default {
name: 'HelloWorld',
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
}
}
</script> <!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
font-weight: normal;
}
ul {
list-style-type: none;
padding: ;
}
li {
display: inline-block;
margin: 10px;
}
a {
color: #42b983;
}
</style>
最新文章
- ****LINUX命令(含GIT命令)个人总结
- MVC5中,加载分部视图,常见的方式
- 网站tomcat配置
- Linux内核中的中断
- 实现类似QQ的即时通信程序(十一)
- 【转】Android项目中编译 C的模块
- ASP.net中的Cache使用介绍
- java反射技术
- Ubuntu 10.04下安装Opengl glx
- 对position的理解
- JS代码整洁随笔
- Ambari Agent 源码分析
- e.stopPropagation()兼容性处理
- linux上安装mysql,亲试成功
- 关于“.bash_profile”和“.bashrc”区别的总结
- LeetCode 561 Array Partition I 解题报告
- f5健康检查
- plsql 导出查询结果
- SQL Server 存储过程 (需整理)
- delphi Firemonkey ListView 使用参考
热门文章
- Python调用Redis
- 当h5页面图片加载失败后,给定一个默认图
- python进程基础点整理
- Android 在Fragment中修改Activity中的控件
- zookeeper的java问题
- Typescript使用字符串联合类型代替枚举类型
- Vue的MVVM框架理解
- error: (-215:Assertion failed) !_src.empty() in function &#39;cv::cvtColor&#39;
- Sql之for update
- more than 120 seconds|hung_task_timeout_secs 什么鬼?