当前位置:首页 » 硬盘大全 » elementui切换页面时缓存数据
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

elementui切换页面时缓存数据

发布时间: 2022-10-04 06:28:30

㈠ element-ui Table表格加载数据过多时,页面会很卡,怎么处理

https://github.com/livelyPeng/pl-table 一个表格组件(完美解决万级数据渲染卡顿问题),流畅渲染万级数据并不会影响到el-table的原有功能

㈡ elementUI 常见问题及解决办法

https://..com/question/1899527108513434180.html

https://segmentfault.com/q/1010000012604150

https://segmentfault.com/q/1010000018747589

https://segmentfault.com/q/1010000023266974
https://blog.csdn.net/weixin_35714733/article/details/112443431

https://blog.csdn.net/weixin_46535287/article/details/121691889

https://blog.csdn.net/weixin_45309872/article/details/94553187

https://blog.csdn.net/cofecode/article/details/77979792

https://www.cnblogs.com/kevinyeah/p/11084121.html

https://blog.csdn.net/CarryBest/article/details/79959389

https://blog.csdn.net/cofecode/article/details/78539975

https://my.oschina.net/yxmBetter/blog/1647679

https://blog.csdn.net/qq_33769914/article/details/81324267

https://segmentfault.com/q/1010000019699116

https://blog.csdn.net/qq_29091239/article/details/84592828

https://blog.csdn.net/qq_33769914/article/details/81324267

https://blog.csdn.net/weixin_30381793/article/details/99770854

https://www.jianshu.com/p/1405f389fb1d
https://blog.csdn.net/qq_41688165/article/details/80834842

文件大小限制: https://blog.csdn.net/weixin_39616772/article/details/84229536
案例参考: https://www.cnblogs.com/yysbolg/p/10516144.html

https://www.cnblogs.com/lyyguniang/p/9850696.html

https://blog.csdn.net/github_37847992/article/details/80390673

https://www.cnblogs.com/liuruolin/p/7517470.html

https://www.cnblogs.com/fangnianqin/p/9549900.html

https://blog.csdn.net/qq_32340877/article/details/80272155

https://www.jianshu.com/p/b3e40837ec1d

https://blog.csdn.net/xr510002594/article/details/86245903

https://blog.csdn.net/suprezheng/article/details/86586902

https://www.cnblogs.com/web-cuicui/p/12629079.html

https://blog.csdn.net/leeleejoker/article/details/80886278

https://blog.csdn.net/qq_33769914/article/details/82800962

https://segmentfault.com/q/1010000010269763

https://blog.csdn.net/weixin_42124196/article/details/101283932

https://www.jianshu.com/p/229d4a8b871e

https://www.cnblogs.com/mlllily/p/12761280.html

1、表单上加 rules {}
2、el-form-item 单个添加 :rules=“[{require: true, message: '请输入内容'}]”
3、动态增减表单项
https://segmentfault.com/a/1190000020410128?utm_source=tag-newest

https://blog.csdn.net/pnjtvxcp/article/details/90176034

https://blog.csdn.net/qq_36437172/article/details/107348939

https://segmentfault.com/q/1010000015393449

https://segmentfault.com/q/1010000012309004

https://www.jianshu.com/p/63bfbbbd1e82

https://blog.csdn.net/xiao_shutong/article/details/77145912

https://segmentfault.com/q/1010000011579964

https://blog.csdn.net/qq_28773851/article/details/89212633

https://www.cnblogs.com/shanxinxin/p/13141434.html

https://..com/question/589271034747602805.html

https://blog.csdn.net/rickiyeat/article/details/76595390

https://blog.csdn.net/qq_19872525/article/details/90526606

https://blog.csdn.net/jokren/article/details/86065217

http://www.imooc.com/wenda/detail/527251

https://blog.csdn.net/qq_35504206/article/details/80093740

https://www.jianshu.com/p/5755f282fcab

https://www.cnblogs.com/Mr-Rshare/p/9777340.html

https://www.cnblogs.com/liujiazhu/archive/2004/01/13/8581762.html

https://blog.csdn.net/Make_Progress365/article/details/103888024

https://blog.csdn.net/qq_32593725/article/details/79194321

㈢ element ui树形控件多选功能的使用

树形控件使用文档

一、获取选中的值

        方法:check() 在复选框改变时触发

        参数:当前操作的节点数据、树目前的选中状态对象,包含 checkedNodes、checkedKeys、halfCheckedNodes、halfCheckedKeys 四个属性 

二、懒加载

        方法:load() 在渲染树加时载且只加载一次,会缓存每次懒加载获得的子节点数据

        参数:node,resolve

        出现问题:由于在懒加载模式下,渲染的树不会动态更新。如果在一个页面里,使用同一个树渲染数据,但是根据不同条件渲染的数据不同,需要重新渲染树。

        解决方式:1)在load方法中,记录下渲染第一层的node和resolve   2) 在需要重新渲染树的方法中再次调用loadNode()

㈣ element-ui弹窗组件再次打开时残留上次打开时的数据

原因:vue指令v-if具有缓存效果,上次打开保存的数据依然保留着;

解决:在dialog关闭的时候清除数据,

可以封装为全局方法:

㈤ ElementUI--Table

```

<template>

  <div>

    <el-row :gutter="10">

      <el-col :span="6">

        <el-button type="primary" size="mini"  @click="handleSelection"

          >获取选中的行</el-button

        >

      </el-col>

    </el-row>

     <!-- el-row :gutter:分栏间隔 -->

    <!-- el-col :offset:分栏偏移 -->

    <!-- el-row type="flex"对齐方式 -->

    <el-table

      :data="tableData"

      border

      stripe

      height="300px"

      style="width: 100%"

       @selection-change="handleSelectionChange"

    >

       <!-- 通过:data属性--绑定数据 -->

      <!-- border:竖向边框 -->

      <!-- stripe:斑马线效果,即隔行换色效果 -->

      <!-- height:固定表头,即固定表格table的高度,超出显示滚动条,在内部滚动 -->

      <!-- @selection-change="handleSelectionChange" => 获取到当前选中的行 -->

      <el-table-column

        header-align="center"

        align="center"

        type="selection"

      ></el-table-column>

      <el-table-column

        header-align="center"

        align="center"

        label="序号"

        type="index"

        width="100"

      >

      </el-table-column>

      <el-table-column prop="date" label="日期" width="180"></el-table-column>

       <!-- fixed="left" -->

       <!-- fixed:固定列,需要固定谁就给谁添加,left/right -->

      <!-- prop:用来决定展示哪一个属性的值;label:设置表格头 -->

      <!-- header-align:表头显示方式 -->

      <!-- align:首列显示方式 -->

      <!-- type:序列号index/多选框selection -->

      <el-table-column label="姓名" prop="name"></el-table-column>

      <el-table-column label="地址" prop="address"></el-table-column>

      <el-table-column header-align="center" align="center" label="操作">

        <template  slot-scope="scope" >

          <el-button

            type="primary"

            icon="el-icon-edit"

            size="mini"

             @click="handleEiit(scope.row)"

            >编辑</el-button

          >

          <el-button

            type="danger"

            icon="el-icon-delete"

            size="mini"

             @click="handleDelete(scope.row)"

            >删除</el-button

          >

           <!-- scope.row 获取当前行的数据 -->

        </template>

      </el-table-column>

    </el-table>

  </div>

</template>

<script>

export default {

  name: "Table",

  methods: {

    handleSelectionChange(value) {

      console.log(value);  //默认会返回,所有选中的行;获取到当前选中的行

      this.selections = value;  //为value赋值

    },

    handleSelection() {

      console.log(this.selections);  //通过selections事件,不断的去记录当前选中的数据

    },

    handleEiit(row) {

      console.log(row);

    },

    handleDelete(row) {

      console.log(row);

    },

  },

  data() {

    return {

      selections: [],  //默认没有选择,保存选中数据

      tableData: [

        { date: "2020-01-01", name: "小不点儿", address: "河北省保定市" },

        { date: "2020-02-02", name: "张三", address: "河北省保定市" },

        { date: "2020-03-03", name: "王五", address: "河北省保定市" },

        { date: "2020-04-01", name: "李四", address: "河北省保定市" },

        { date: "2020-05-01", name: "赵晴", address: "河北省保定市" },

        { date: "2020-06-01", name: "冯峰", address: "河北省保定市" },

        { date: "2020-07-01", name: "小一", address: "河北省保定市" },

        { date: "2020-08-01", name: "大张", address: "河北省保定市" },

        { date: "2020-09-01", name: "吴助", address: "河北省保定市" },

      ],

    };

  },

};

</script>

```

㈥ Element UI 基本使用

1:npm 安装

推荐使用 npm 的方式安装,它能更好地和  webpack  打包工具配合使用。

npm i element-ui -S,

2:引入 Element

你可以引入整个 Element,或是根据需要仅引入部分组件。我们先介绍如何引入完整的 Element。

2.1完整引入

在 main.js 中写入以下内容:

import Vue from 'vue'

import App from './App.vue'

import ElementUI from 'element-ui';//全局引入

import 'element-ui/lib/theme-chalk/index.css';

Vue.config.proctionTip = false

//Vue.use(ElementUI)

Vue.use(Button)

Vue.use(Aside)

Vue.use(Main)

Vue.use(Container)

new Vue({

  render: h => h(App),

}).$mount('#app')

2.2按需引入

借助  babel-plugin-component ,我们可以只引入需要的组件,以达到减小项目体积的目的。

首先,安装 babel-plugin-component:

在命令行输入

npm install babel-plugin-component -D

然后,将 .babelrc 修改为://等同于 babel.config.js文件

mole.exports = {

  presets: [

    '@vue/cli-plugin-babel/preset',

    ["@babel/preset-env", { "moles": false }]

  ],

  "plugins": [

    [

      "component",

      {

        "libraryName": "element-ui",

        "styleLibraryName": "theme-chalk"

      }

    ]

  ]

}

2.2.1在main.js配置

import Vue from 'vue'

import App from './App.vue'

 import {Button,Aside,Main,Container} from 'element-ui';//按需引入 注:Container首字母大写

import 'element-ui/lib/theme-chalk/index.css';

Vue.config.proctionTip = false

//Vue.use(ElementUI)

Vue.use(Button)

Vue.use(Aside)

Vue.use(Main)

Vue.use(Container)

new Vue({

  render: h => h(App),

}).$mount('#app')

小菜刚学会element_ui组件使用,如何全局引入库文件太大,开发时浪费资源,希望大神们多指教

㈦ element-ui中的table可分页多选功能-记住上一页勾选数据

vue中使用el-table,点击下一页后常需要记住上一页所勾选的数据

2.然后第一列,即有多选框的一列,添加:reserve-selection="true"

3.然后在methods中添加函数:

如果需要清除勾选数据(刷新也页面跳转后会自动清除)

㈧ elementUI的Table 表格问题

在开发vue框架项目时,引入element插件,使用table表格组件时,遇到了一些问题,以下列出以供参考。

如上图,在当前导航表格table样式是没问题的,但当我点击别的导航去到另外的页面,然后再回到之前的导航页面,表格table的样式就会混乱,随便点击当前页面或刷新亦或拉伸页面,样式又恢复正常,很奇怪的样式问题。
打开调试之后,发现table的宽度并没有按照100%来显示,而是根据表格宽度值来计算的(我这里是640px),并且在table标签底下发现了colgroup和col标签,colgroup包裹着对应单元格数的col,并且col的宽度为80px,瞬间恍然大悟,明白640px是怎么得来的,这里一共有8个单元格,8*80就是640px了,那要怎么解决这个默认样式呢?
一、给表格添加固定宽度

二、利用flex的特性

2.table表格数据问题
table显示的数据并不是一成不变的,这里传入table的data需要有实时监控的功能,其中一个数据的改变就要及时显示,这里我用计算属性computed来进行监控。有时候后台返回的状态数据是0,1等等,我们也可以在里面进行判断渲染。

3.table表格的排序、筛选

4.表头添加Tooltip 文字提示

今天的心得就到这儿了,希望可以帮助到有需要的小伙伴儿O(∩_∩)O

㈨ element-ui输入框怎么修改建议显示模版

<script>import Vue from 'vue'Vue.component('my-remote', { functional: true, render: function(h, ctx) { var item = ctx.props.item; let str = h('li', ctx.data, [ h('div', { attrs: { class: 'name' } }, [item.value]), h('span', { attrs: { class: 'addr' } }, [item.address]) ]); if (item.str) { // 根据参数不同 修改原模版结构 str = h('center', { attrs: { class: 'ems' } }, [item.str]) } return str }, props: { item: { type: Object, required: true } }}); export default { data() { return { restaurants: [], state: '', timeout: null, _that: {} // 记录this,用来发起http请求 }; }, methods: { querySearch(queryString, cb) { let restaurants = this.restaurants; if (restaurants.length > 0) { // 如果参数都没变化,则使用缓存数据,避免请求沉积 let results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants; cb(results); } else { const qtype = ‘参数’; this._that.$http('/inner', { qtype: qtype }) .then((res) => { restaurants = this.loadAll(res); this.restaurants = restaurants; let results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants; cb(results); }) .catch((err) => { restaurants = this.loadAll(); let results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants; cb(results); }); } }, createFilter(queryString) { return (restaurant) => { if (restaurant.str) return false; return (restaurant.value.indexOf(queryString) >= 0); }; }, loadAll(data) { let serier = []; if (data) { for (let i = 0, l = data.length; i < l; i++) { let a = data[i]; let b = ''; if (typeof a === "object") { b = a[1]; a = a[0]; } serier.push({ "value": a, "address": b }) } } else { // 如果没有请求到数据,则显示暂无数据! serier.push({ "str": '暂无数据' }) } return serier; }, handleIconClick(ev) { this.state = ""; } }, mounted() { this._that = this; }}