自学内容网 自学内容网

若依框架常见问题

1.展开某一导航栏时所有导航栏会全部展开

        将SidebarItem.vue中的:index=“resolvePath(item.path)” 改为 :index=“resolvePath(onlyOneChild.path)”

2.使用axios发送请求

       
del(){
         const formData = new FormData();
         formData.append(key,value); 
           //无上述两行代码数据不以请求表单的方式发送

         try {
              axios.post('http://***********', formData,{
                headers: {
                  'token': token
                }
              }).then(response => {
                if(response.data.code === '0' && response.data.msg === ""){
                  this.$modal.msgSuccess(delWords[i]+"删除成功");
                  this.getList();
                }else{
                  this.$modal.msgSuccess( response.data.msg);
                }
              });
            } catch (error) {
              console.error('发送数据时出错:', error);
            }
}

3.使用this.$modal.confirm弹窗之后this会失效,无法获取this.****

      在使用this.$modal.confirm弹窗前先定义变量并将数据赋值给该变量

      /** 删除按钮操作 */
      handleDelete(row) {
        const delWords=this.words;
        const token=this.jqtoken;
        this.$modal.confirm('是否确认删除单词"' + delWords + '"的数据项?').then(function() {
          for(var i=0;i<delWords.length;i++){
            const formData = new FormData();
            formData.append('word', delWords[i]); // 假设你要发送的字段名为 'word'
            try {
              axios.post('http://********************', formData,{
                headers: {
                  'token': token
                }
              }).then(response => {
                if(response.data.code === '0' && response.data.msg === ""){
                  this.$modal.msgSuccess(delWords[i]+"删除成功");
                  this.getList();
                }else{
                  this.$modal.msgSuccess( response.data.msg);
                }
              });
            } catch (error) {
              console.error('发送数据时出错:', error);
            }
          }

        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch((error) => {
          this.$modal.msgWarning("删除失败:"+error);
        });
      },

4.若依在使用某些未设置权限的按钮或者调用某些其它系统的接口时提示当前操作没有权限

        (1)取消按钮的权限设置,删掉代码v-hasPermi="['system:information:edit']"

        (2)取消获取角色的代码

        this.postOptions = response.posts;
        this.roleOptions = response.roles;

        将

        getUser().then(response => {
          this.postOptions = response.posts;
          this.roleOptions = response.roles;
          this.open = true;
          this.title = "添加单词";
        });

变化为

          this.open = true;
          this.title = "添加单词";


原文地址:https://blog.csdn.net/qq_55946937/article/details/142787134

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!