错误:ERROR Cannot read properties of null (reading ‘type‘)

这篇具有很好参考价值的文章主要介绍了错误:ERROR Cannot read properties of null (reading ‘type‘)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

ERROR
Cannot read properties of null (reading ‘type’)
TypeError: Cannot read properties of null (reading ‘type’)

错误:ERROR Cannot read properties of null (reading ‘type‘),分布式小程序电商,javascript,vue.js,前端

<template>
  <el-card>
    <el-row :gutter="20" class="header">
      <el-col :span="7">
        <el-input placeholder="请输入商品大类名称..." v-model="queryForm.query" clearable></el-input>
      </el-col>
      <el-button type="primary" :icon="Search" @click="initBigTypeList">搜索</el-button>
      <el-button type="primary" :icon="DocumentAdd" @click="handleDialogValue()">添加商品大类</el-button>
    </el-row>
    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column prop="id" label="#ID" width="80" />
      <el-table-column prop="name" label="商品大类名称" width="200" />
      <el-table-column prop="image" label="商品大类图片" width="200">
        <template v-slot="scope">
          <img :src="getServerUrl()+'/image/bigType/'+scope.row.image" width="80" height="80"/>
        </template>
      </el-table-column>
      <el-table-column prop="remark" label="商品大类描述"/>
      <el-table-column prop="action" label="操作" width="300" fixed="right">
        <template v-slot="scope">
          <el-button type="success" @click="handleImageDialogValue(scope.row)">更换图片</el-button>
          <el-button type="primary" :icon="Edit" @click="handleDialogValue(scope.row.id)"/>
          <el-button type="danger" :icon="Delete" @click="handleDelete(scope.row.id)"/>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
        v-model:currentPage="queryForm.pageNum"
        v-model:page-size="queryForm.pageSize"
        :page-sizes="[10, 20, 30, 40,50]"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
    />
  </el-card>
  <Dialog v-model="dialogVisible" :dialogVisible="dialogVisible" :id="id" :dialogTitle="dialogTitle" @initBigTypeList="initBigTypeList"></Dialog>
  <ImageDialog v-model="imageDialogVisible" :imageDialogValue="imageDialogValue" @initBigTypeList="initBigTypeList"></ImageDialog>
</template>

<script setup>
import { Search,Delete,Edit,DocumentAdd } from '@element-plus/icons-vue'
import { ref } from 'vue'
import axios,{ getServerUrl } from "@/util/axios";
import Dialog from './components/dialog'
import ImageDialog from './components/imageDialog'
import {ElMessage, ElMessageBox} from "element-plus";

const queryForm=ref({
  query:'',
  pageNum:1,
  pageSize:10
})

const total=ref(0)

const tableData = ref([])

const id=ref(-1)

const dialogTitle=ref('')

const dialogVisible=ref(false)

const imageDialogVisible=ref(false)

const imageDialogValue=ref({})

const initBigTypeList=async()=>{
  const res=await axios.post("admin/bigType/list",queryForm.value)
  tableData.value=res.data.bigTypeList;
  total.value=res.data.total;
}

initBigTypeList();

const handleSizeChange=(pageSize)=>{
  queryForm.value.pageNum=1;
  queryForm.value.pageSize=pageSize;
  initBigTypeList();
}

const handleCurrentChange=(pageNum)=>{
  queryForm.value.pageNum=pageNum;
  initBigTypeList();
}

const handleDialogValue=(bigTypeId)=>{
  console.log("handleDialogValue"+bigTypeId);
  if(bigTypeId){
    id.value=bigTypeId;
    dialogTitle.value="商品大类修改"
  }else{
    id.value=-1;
    dialogTitle.value="商品大类添加"
  }
  dialogVisible.value=true
}

const handleImageDialogValue=(row)=>{
  imageDialogVisible.value=true
  imageDialogValue.value=JSON.parse(JSON.stringify(row))
}


const handleDelete=(id,status)=>{
  ElMessageBox.confirm(
      '您确定要删除这条记录吗?',
      '系统提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }
  )
      .then(async() => {
        let res=await axios.get('admin/bigType/delete/'+id)
        if(res.data.code==0){
          ElMessage({
            type: 'success',
            message: '删除成功',
          })
          initBigTypeList();
        }else{
          ElMessage({
            type: 'error',
            message: res.data.msg,
          })
        }

      })
      .catch(() => {

      })
}


</script>

<style lang="scss" scoped>

.header{
  padding-bottom: 16px;
  box-sizing: border-box;
}

.el-pagination{
  padding-top: 15px;
  box-sizing: border-box;
}



</style>
<template>
  <el-dialog
    :model-value="dialogVisible"
    :title="dialogTitle"
    width="30%"
  @close="handleClose"
  >

    <el-form
        ref="formRef"
        :model="form"
        :rules="rules"
        label-width="100px"
    >
      <el-form-item label="大类名称" prop="name">
        <el-input v-model="form.name" />
      </el-form-item>
      <el-form-item label="大类描述" prop="remark">
        <el-input v-model="form.remark" type="textarea" :rows="4"/>
      </el-form-item>


    </el-form>
    <template #footer>
      <span class="dialog-footer">

        <el-button  @click="handleClose">取消</el-button>
     <el-button type="primary" @click="handleConfirm">确认</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script setup>

import {defineEmits, defineProps, ref, watch} from "vue";
import axios from "@/util/axios";
import { ElMessage } from 'element-plus'

  const tableData=ref([])



  const props=defineProps(
      {
        id:{
          type:Number,
          default:-1,
          required:true
        },
        dialogTitle:{
          type:String,
          default:'',
          required:true
        },
        dialogVisible:{
          type:Boolean,
          default:false,
          required:true
        }
      }
  )


const form=ref({
  id:-1,
  name:"",
  remark:""
})

const rules=ref({
  name:[
    { required: true, message: '请输入商品大类名称'}
  ],
  remark:[
    { required: true, message: '请输入商品大类描述'}
  ]
})

const formRef=ref(null)

const initFormData=async(id)=>{
  const res=await axios.get("admin/bigType/"+id);
  form.value=res.data.bigType;
}



  watch(
      ()=>props.dialogVisible,
      ()=>{
        let id=props.id;
        if(id!=-1){
          initFormData(id)
        }else{
          formRef.value.resetFields();
          form.value={
            id:-1,
            name:"",
            remark:""
          }
        }
      }
  )


  const emits=defineEmits(['update:modelValue','initBigTypeList'])

  const handleClose=()=>{
    emits('update:modelValue',false)
  }

  const handleConfirm=()=>{
    formRef.value.validate(async(valid)=>{
      if(valid){

          let result=await axios.post("admin/bigType/save",form.value);
          let data=result.data;
          if(data.code==0){
            ElMessage.success("执行成功!")
            formRef.value.resetFields();
            emits("initBigTypeList")
            handleClose();
          }else{
            ElMessage.error(data.msg);
          }


      }else{
        console.log("fail")
      }
    })
  }

</script>

<style scoped>

</style>

改正后:单位找到原因
错误:ERROR Cannot read properties of null (reading ‘type‘),分布式小程序电商,javascript,vue.js,前端文章来源地址https://www.toymoban.com/news/detail-744781.html

到了这里,关于错误:ERROR Cannot read properties of null (reading ‘type‘)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • ❤ cannot read properties of null(reading appendChild)解决办法

    写的一个js渲染,但是出了个小问题,cannot read properties of null(reading appendChild)报错。 大致意思是:不能读取空的属性。 1、console.log() //打印数据内容,查看获取数据是否有问题。 2、js引入放body最后面,页面是自上而下的运行的,HTML都没有运行到,当然获取不到对应节点 3、

    2024年02月14日
    浏览(31)
  • “TypeError: Cannot read properties of null (reading ‘getContext‘)“

    目录 一、报错截图 二、使用场景 三、代码截图 四、报错原因  五、解决办法 第一次在vue项目种使用canvas,跟着网上教程做,标签canvas写好了,dom元素获取了,简单“画”了一下,运行之后报\\\"TypeError: Cannot read properties of null (reading \\\'getContext\\\')\\\"的错。 意思是:找不到getContex

    2024年02月16日
    浏览(38)
  • Uncaught TypeError: Cannot read properties of null (reading ‘getAttribute‘)

    简述:vue项目报错, Uncaught TypeError: Cannot read properties of null (reading \\\'getAttribute\\\') , 翻译:无法读取null属性(读取\\\'getAttribute\\\'), 解析:getAttribute()是js获取属性方法,就是getAttribute不能读取null的属性, 这种错误一般出现在使用Echarts和地图后,当切换到空白页面后,重置页面时,

    2024年02月11日
    浏览(40)
  • Uncaught TypeError: Cannot read properties of null (reading ‘style‘)

    Uncaught TypeError: Cannot read properties of null (reading \\\'style\\\') 2:报错的原因 文档的加载过程是自上向下加载。使用未命名的变量、会报错 3;解决办法 1、将Javascript代码从标签中放入body中 2、 window.onload = function(){}框起来

    2024年02月15日
    浏览(28)
  • easyui Uncaught TypeError: Cannot read properties of null (reading ‘width‘)

    问题描述 在将easyui1.3.6版本替换为1.7版本的时候。只有表头显示出来了,内容并没有显示出来,且报异常。表头也没有按照期望的宽度正常显示。错误提示如下 问题原因及解决办法 该问题出现的原因是因为该表格的表头涉及到跨行跨列问题,原因是最后一栏出货记录的跨列

    2024年02月16日
    浏览(36)
  • 当vue3 报错 Cannot read properties of null (reading ‘style‘)

    当你在编写代码时 发现页面不及时刷新了 浏览器控制台报下面的错误 时刚看到的时候会一很懵 那么原因是什么呢 原因是:尽管Vue 3允许一个组件模板中存在多个元素,但是如果你这样写,有时会出现上述错误。 解决方法:在模板内你写的多个标签外面包裹一层元素,或者

    2024年02月12日
    浏览(40)
  • 配置hexo时TypeError: Cannot read properties of null (reading ‘xxx‘)

    这种报错的含义是在读取文件时读到了空对象。一般是文件放错了位置导致程序在指定的位置读不到想要的文件导致的。 我是在更换hexo的theme时遇到的问题,我直接把github上的theme文件clone到了hexo的根目录下了才有了这样的报错。 只要把clone下来的theme文件保存到hexo根目录下

    2024年02月11日
    浏览(42)
  • Uncaught TypeError: Cannot read properties of null (reading ‘name‘) 和NoSuchMethodException

    分析:这是由于还没登录,data.name 还没获取到值,所以为null 方法1:可以不管,它不会影响其他功能,当你登录后,便不会报这个错 方法2:给它一个if判断是否为null 修改前: 修改后: 修改完后记得先清楚浏览器缓存(或换个浏览器)再测试。成功解决! 还有一个问题是缺

    2024年02月12日
    浏览(34)
  • npm ERR!Cannot read properties of null(reading ‘pickAlgorithm’)报错问题解决

    当在使用npm包管理器或执行npm命令时,有时候会遇到“npm ERR!Cannot read properties of null(reading ‘pickAlgorithm’)”这个错误提示,这是一个常见的npm错误。 这个错误提示通常说明在使用npm包管理器时,执行了某个npm命令,但是在执行这个命令的过程中,出现了问题,可能是由于某

    2024年02月12日
    浏览(30)
  • Uncaught (in promise) TypeError: Cannot read properties of null (reading ‘brands)

    在写vue项目时我们经常会遇见这种报错, 报错: Uncaught (in promise) TypeError: Cannot read properties of null (reading \\\'brands\\\') 这句话意思是:无法读取null属性(读取\\\'brands\\\')  解决办法是在需要渲染的地方加一个v-if来判断数据存在 如下图 搞定!! 

    2024年02月11日
    浏览(37)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包