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

相关推荐
CrystalShaw1 小时前
[AI codec]opus-1.6\DRED 编码侧 学习笔记
笔记·学习
张张123y1 小时前
RAG从0到1学习:技术架构、项目实践与面试指南
人工智能·python·学习·面试·架构·langchain·transformer
·醉挽清风·1 小时前
学习笔记—Linux—文件IO
linux·服务器·学习
Accerlator1 小时前
计算机网络学习
学习·计算机网络
星爷AG I1 小时前
14-12 动作序列学习(AGI基础理论)
人工智能·学习·agi
澄澈青空~2 小时前
Unity3D VR 游戏开发 — 技术路线与学习路线完整大纲
学习·vr
kuntli3 小时前
Vue生命周期全解析
vue.js
小一梦4 小时前
宝塔面板单域名部署多个 Vue 项目:从路径冲突到完美共存
服务器·javascript·vue.js