首页 > 其他分享 >VUE学习笔记(四)

VUE学习笔记(四)

时间:2024-05-27 16:24:26浏览次数:16  
标签:VUE const 对话框 笔记 学习 reactive vue 组件 import

通过子组件实例实现对话框的打开

AddCategory.vue页面里

调整dialogvue里按钮事件

<div class="dialog-footer">
                <el-button @click="state.dialogVisible = false">Cancel</el-button>
                <el-button type="primary" @click="state.dialogVisible = false">
                    Confirm
                </el-button>
            </div>

 

script脚本更新

<script setup>
import { reactive } from 'vue'
const state = reactive({
    dialogVisible: false
})
///----------------------------------
//打开对话框
const dialogCategory = () => {
    state.dialogVisible = true;

}
//关闭对话框
const handleClose = (done) => {
    state.dialogVisible = false;
    done();
}
//主动暴露给父组件,编译器的宏命令,不需要引入
defineExpose({
    dialogCategory
})

</script>

 

src下views文件夹里的CategoryView.vue

<template>
    <el-card class="box-card">
        <template #header>
            <div class="card-header">
                <span>商品分类</span>
                <el-button type="primary" icon="CirclePlus" round @click="handleDialog()">添加分类</el-button>
            </div>
        </template>
        <el-table :data="tableData.list" stripe style="width: 100%">
            <el-table-column prop="id" label="Id" width="180" />
            <el-table-column prop="name" label="名称" width="180" />
            <el-table-column fixed="right" label="操作" width="180">
                <template #default>
                    <el-button type="success" size="small">
                        修改
                    </el-button>
                    <el-button type="danger" size="small">删除</el-button>
                </template>
            </el-table-column>
        </el-table>

    </el-card>
    <AddCategoryVue ref="addCategoryRef"></AddCategoryVue>
</template>

script脚本添加打开分类页

<script setup>

import { onMounted, reactive, ref } from 'vue'
import axios from "@/api/api_config.js"

import AddCategoryVue from '@/components/AddCategory.vue'

///----------------------------------
const tableData = reactive({ list: [] })
const addCategoryRef = ref(null)//获取子组件实例
///----------------------------------

onMounted(() => {
    getList()
})

//获取分类信息
const getList = () => {
    return axios.get('/category').then((res) => {
        tableData.list = res.data
    })
}

//打开分类页
const handleDialog = () => {
    addCategoryRef.value.dialogCategory()//调用子组件方法
}

</script>

 

标签:VUE,const,对话框,笔记,学习,reactive,vue,组件,import
From: https://www.cnblogs.com/Lvkang/p/18215805

相关文章

  • 抽象代数学习笔记(环论、域论)
    RingTheory4.8Definition:Aring\(R\)isasettogetherwithtwobinaryoperationtogetherwith"\(+\)"and"\(\times\)",obeying:\((R,+)\)isanAbeliangroup.\(\times\)isassociative:\((a\timesb)\timesc=a\ti......
  • 基于yolov2深度学习网络的单人口罩佩戴检测和人脸定位算法matlab仿真
    1.算法运行效果图预览   2.算法运行软件版本MATLAB2022A 3.算法理论概述      基于YOLOv2(YouOnlyLookOnceversion2)深度学习网络的单人口罩佩戴检测和人脸定位算法是一种结合了目标检测与特征识别的综合性解决方案,主要用于自动检测图像或视频中人物......
  • mit6.828笔记 - lab5(上)- Spawn and Shell
    SpawningProcess有了文件系统了,我们终于可以方便地读取磁盘中的文件了。到目前为止,我们创建进程的方法一直都是在编译内核的时候将程序链接到数据段,在i386_init通过ENV_CREATE宏创建。现在我们应该考虑通过文件系统直接将用户程序从硬盘中读取出来,spawn就是这样的东西。s......
  • 3D Gaussian SLAM学习笔记一.Gaussian-SLAM配置运行
    ​研一小白,最近在做SLAM的科研工作,在一定的调研后,发现3DGaussianSplatting这个方向不错,于是跑一下这方面的代码。论文链接:https://arxiv.org/pdf/2312.10070.pdf代码链接:https://github.com/VladimirYugay/Gaussian-SLAM项目测试首先克隆代码,不过我觉得直接下载zip包......
  • 学习GitEgg
    GitEgg1.环境搭建在已经安装好docker服务器使用docker-compose部署mysql,redis,nacos其中nacos是我本地已经生成的jar包。在服务器上保持这个目录环境:对应的docker-compose文件:version:'3.2'services:mysql:image:mysql:8.0.31container_name:mysqle......
  • day10今日笔记
    今日笔记grepgrep是对数据进行过滤查找关键字源数据可以是文件内容grephello/opt/hello.txt,找出存在hello的那一行命令的执行结果,这个需要结合管道符使用,cat/etc/passwd|grep'root'测试数据Iteachlinux.Ilikepython.Myqqis877348180.Mynameis......
  • vue使用右击复制功能
      使用的库xe-clipboard右击复制的 实际使用到的库是xe-clipboard 参考的https://vxetable.cn/v4/#/table/advanced/menu<template><div><vxe-tablebordershow-footer:row-config="{isCurrent:true}":column-config=&q......
  • 梦断代码阅读笔记06
    梦断代码阅读笔记06阅读总结在阅读《梦断代码》这本书后,我深刻感受到编程不仅是一种技能,更是一种思维方式,它对日常生活中的问题解决和思考方式有着深远的影响。通过这本书,我学到了编程思维的重要性。书中强调了逻辑思维、创造性、自动化、数据分析和解决复杂问题的能力,这些都是......
  • VUE学习笔记(三)
    本小节为设置跨域和axios请求和获取数据设置跨域,在vue.config.js添加devServer配置const{defineConfig}=require("@vue/cli-service");module.exports=defineConfig({transpileDependencies:true,devServer:{proxy:{"/api":{target:&q......
  • 【php开发系统性学习】——thinkphp框架的控制器和视图的精简详细的使用
    ......