Vue小白学习笔记

Vue基础配置

main.js(入口文件)

javascript 复制代码
import Vue from 'vue'
import App from './App.vue'
import router from './router'

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')

index.html(默认首页)

html 复制代码
<!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>

Vue组件文件以.vue结尾每个部分由<template>,<script>,<style>组成。

html 复制代码
<template>
  <!-- HTML代码部分 -->
  <div id="app">
    <h1>{{ message }}</h1>
  </div>
</template>


<script>
// JS代码部分
export default {
  // 数据模型
  data () {
    return {
      message:"Hello Vue"
    }
  }
  // 方法
  methods: {
    
  }
}
</script>



<style>
/* css样式 */

</style>

Vue组件

table button

html 复制代码
<template>
  <div>
    <!-- 按钮组件 -->
    <el-row>
      <el-button>默认按钮</el-button>
      <el-button type="primary">主要按钮</el-button>
      <el-button type="success">成功按钮</el-button>
      <el-button type="info">信息按钮</el-button>
      <el-button type="warning">警告按钮</el-button>
      <el-button type="danger">危险按钮</el-button>
    </el-row>
    <br /><br /><br />

    <!-- 表格组件 -->
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="date" label="日期" width="180"> </el-table-column>
      <el-table-column prop="name" label="姓名" width="180"> </el-table-column>
      <el-table-column prop="address" label="地址"> </el-table-column>
    </el-table>

    <!-- 分页组件 -->
    <el-pagination
      background
      layout="total,prev, pager, next,jumper,sizes"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :total="1000"
    >
    </el-pagination>
  </div>
</template>


<script>
export default {
  data() {
    return {
      tableData: [
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1517 弄",
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1519 弄",
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1516 弄",
        },
      ],
    };
  },
  methods: {
    handleSizeChange(val) {
      alert("页面显示改变为:" + val);
    },
    handleCurrentChange(val) {
      alert("页码改变为:" + val);
    },
  },
};
</script>


<style>
</style>

页码条设置

与以下一一对应

java 复制代码
total,prev, pager, next,jumper,sizes 

调整页面方法

html 复制代码
    @size-change="handleSizeChange"
      @current-change="handleCurrentChange"

其他组件详细请看文档,CV大神

相关推荐
摇滚侠1 分钟前
2025最新 SpringCloud 教程,Gateway-断言-Query,笔记56
笔记·spring cloud·gateway
van久4 分钟前
.Net Core 学习:Razor Pages -- EF Core工作原理
数据库·学习·.netcore
北岛寒沫6 分钟前
北京大学国家发展研究院 经济学辅修 经济学原理课程笔记(第三课 需求与供应弹性)
数据库·人工智能·笔记
清涧游23 分钟前
第九章-NOP团队dmz-A
笔记·学习·安全
sensen_kiss24 分钟前
INT303 Big Data Analysis 大数据分析 Pt.10 分析模型和混合模型
大数据·学习·机器学习·数据挖掘·数据分析
QiZhang | UESTC33 分钟前
学习日记day41
学习
光头程序员37 分钟前
学习笔记——常识解答之垃圾回收机制
java·笔记·学习
爱吃番茄鼠骗1 小时前
Linux操作系统———线程同步
linux·学习
用户555970025101 小时前
Vue学习笔记-项目结构与文件结构分析
vue.js