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大神

相关推荐
凉、介37 分钟前
Armv8-A virtualization 笔记 (二)
笔记·学习·嵌入式·arm·gic
智者知已应修善业2 小时前
【ICL8038芯片正弦波三角波方波发生器电路】2024-1-5
驱动开发·经验分享·笔记·硬件架构·硬件工程
JoneBB2 小时前
ABAP Webservice连接
运维·开发语言·数据库·学习
探序基因2 小时前
身高与基因的关系
笔记
嵌入式小企鹅2 小时前
UiPath推出AI编程“总指挥台”,SiFive发布RISC-V第三代猛兽
人工智能·学习·google·程序员·ai编程·risc-v·开源工具
Ada大侦探3 小时前
新手小白学习数据分析03----Excel 报表之大厂周报(2026最新版实操,包教包会!)
学习·数据分析·excel
-To be number.wan4 小时前
进程与线程的区别
学习·操作系统
llhm4 小时前
tsp学习笔记——LINUX SDK编译2(2)Kernel6.1 Linux
linux·笔记·学习
李白不吃坚果6 小时前
沟道电荷的思考
学习·cmos·集成电路·模拟集成电路设计·沟道电荷
学会870上岸华师6 小时前
C 语言程序设计——第一章课后编程题
c语言·开发语言·学习·算法