vue-element-admin学习笔记

发布于:2022-11-02 ⋅ 阅读:(535) ⋅ 点赞:(0)

1.data functions should return an object

网上很多解决方案是在data()中添加return(),而我出现的问题是其他代码中没有设置接收值。如下:

getInfo({ commit, state }) {
    return new Promise((resolve, reject) => {
      getInfo(state.token).then(response => {
        const { data } = response//里面不是data进不了页面

        if (!data) {
          reject('验证失败,请重新登录')
        }

        const { roles, name, avatar, introduction } = data

        if (!roles || roles.length <= 0) {
          reject('getInfo: roles must be a non-null array!')
        }

const { data } = response最开始没有使用data接收返回值导致前端页面报错。

2.vue控制台出现如下错误。

npm ERR! Error while executing:
npm ERR! D:\git\Git\bin\git.EXE ls-remote -h -t git://github.com/adobe-webplatform/eve.git
npm ERR!
npm ERR! fatal: unable to connect to github.com:
npm ERR! github.com[0: 20.205.243.166]: errno=Unknown error
npm ERR!
npm ERR!
npm ERR! exited with error code: 128

1、打开package.json把"tui-editor"删掉

2、将下面文件删除掉。

路由位置:
src/router/modules/components.js 搜索markdown,把相应路由代码删除

components位置:
src/components/MarkdownEditor

运行npm install

3.vue中使用echarts。

3.1终端安装echarts

npm install echarts --save

3.2main.js引入echarts

import * as echarts from 'echarts'
Vue.prototype.$echarts=echarts

3.3页面中使用echarts,一定要注意使用this.$echarts

var myChart = this.$echarts.init(document.getElementById('main'));

4.vue+springboot前后端传递json格式参数,前段传递的json格式数据为

params={
        starttime:starttime,
        endtime:endtime,
      }

后端通过@RequestBody Map<String,Object> params获取json数据,通过params.get("参数名").toString()获得String数据

@PostMapping("/selectAllByDate")
        public Result<List<Rainfall>> selectAllByDate(@RequestBody Map<String,Object> params){
            System.out.println(params.get("starttime").toString());
        }

5.[__ob__: Observer]如何取值?

mounted() {
    setTimeout(() => {
      this.rainfall()
      //这里就写你要执行的语句即可,先让数据库的数据加载进去数组中你在从数组中取值就好了
    }, 800)
  },

然后就可以遍历里面的值。

6.DatePicker日期选择器选择日期之后,后端接收到"2022-10-11T16:00:00.000Z"格式。

<el-date-picker 
    value-format="yyyy-MM-dd" 
    type="date" 
    placeholder="选择日期">    
</el-date-picker>

想要获取"2022-10-11",需要在控件内添加value-format="yyyy-MM-dd"。


网站公告

今日签到

点亮在社区的每一天
去签到