vue 动态组件,传递参数
<template>
<div class="top">
<div class='nav'>
<ul class='navHader'>
<li @click="current='Sunyi'" :class="{active:current=='Sunyi'}">损益完成情况分析表</li>
<li @click="current='Caiwu'" :class="{active:current=='Caiwu'}">财务快报资产分析表</li>
<li @click="current='Jingying'" :class="{active:current=='Jingying'}">经营指标完成情况分析表</li>
</ul>
<Menus></Menus>
</div>
<keep-alive>
<component :is="current" :callbackdata="callbackdata"></component>
</keep-alive>
</div>
</template>
<script> import Menus from "./Button.vue"
import Sunyi from "./Tables/Sunyi.vue"
import Jingying from "./Tables/Jingying.vue"
import Caiwu from "./Tables/Caiwu.vue" export default {
data() {
return {
current: 'Sunyi',
navs: [
'损益完成情况分析表',
'财务快报资产分析表',
'经营指标完成情况分析表',
],
callbackdata:{},//返回数据
}
},
mounted() {
this.toggleSwitch(this.current)
},
methods: {
toggleSwitch(parameter) {
const self = this;
let this_toggle = parameter; switch (this_toggle) {
case 'Sunyi':
self.toggleDatainit('pl');
break;
case 'Caiwu':
self.toggleDatainit('bs');
break;
case 'Jingying':
self.toggleDatainit('t1');
break;
}
},
toggleDatainit(talbel_url) {
const self = this;
self.$http.get('getInitTable/init/'+talbel_url).then(res => {
if(res.data.status == 2000){
console.log(res.data);
self.callbackdata = res;
}
}).then(error => {
});
},
},
components: {
Menus,
Sunyi,
Caiwu,
Jingying
},
watch:{
current(newV){
this.toggleSwitch(newV);
}
}
} </script>
在子组件中接收参数
<script>
import Tools from '../../tools/tools' export default {
data() {
return {
HT: new Tools(),// 实例一个对象
HTobjData: '',// HT的一个大集合
}
},
props: {
callbackdata: {
type: Object,
default: {}
}
},
mounted() { },
methods: {
init(callbackdata) {
const self = this;
self.HTobjData = self.HT.init(callbackdata, self, Handsontable);
}
},
components: {}, watch: {
callbackdata(newV) {
this.init(newV);
}
} } </script>
vue 动态组件,传递参数的更多相关文章
- vue父子组件传递参数之props
vue中父组件通过props传递数据给子组件, props有两种传递方式 1.props:['msg']2.props: { msg:{ type:String, default:"&quo ...
- Vue 给子组件传递参数
Vue 给子组件传递参数 首先看个例子吧 原文 html <div class="container" id="app"> <div clas ...
- Vue动态组件
前面的话 让多个组件使用同一个挂载点,并动态切换,这就是动态组件.本文将详细介绍Vue动态组件 概述 通过使用保留的 <component> 元素,动态地绑定到它的 is 特性,可以实现动 ...
- vue-父组件传递参数到子组件
案例: 父组件 <template> <div id="app"> <h1>vuex</h1> <h3>count:{{ ...
- vue子组件向父组件传递参数的基本方式
子组件: this.$emit('transferUrl', this.picUrl) 父组件: 引入子组件<pics @transferUrl="gettransferUrl&quo ...
- Vue动态组件&异步组件
在动态组件上使用keep-alive 我们之前曾经在一个多标签的界面中使用is特性来切换不同的组件: Vue.js的动态组件模板 <component v-bind:is="curre ...
- vue 父子组件传递数据
单向数据流: 数据从父级组件传递给子组件,只能单向绑定. 子组件内部不能直接修改从父级传递过来的数据. 解决方法: 可以使用data将父组件传递过来的数据拷贝一份存放起来,再修改拷贝的数据就可以了 / ...
- vue单文件组件形成父子(子父)组件之间通信(vue父组件传递数据给子组件,子组件传递数据给父组件)
看了很多文章,官网文档也有看,对父子组件通信说的不是很明白:决定自己总结一下: vue一般都使用构建工具构建项目:这样每个组件都是单文件组件:而网上很多文章都是script标签方式映入vue,组件通信 ...
- Vue父组件传递异步获取的数据给子组件
问题场景: 当父组件传给子组件的数据是在父组件中异步获取的时候,如何让子组件获取期望的值? 在父组件中: 首先在data()中定义data_detail为空: data(){ data_detail: ...
- vue动态组件切换(选项卡)
vue的动态组件 <template :is='变量'></template> 可以通过改变变量,来改变template的替换内容.达到选项卡的功能 如果想要切换保持不重新创建 ...
随机推荐
- 【Java并发】并发队列与线程池
并发队列 阻塞队列与非阻塞队 ConcurrentLinkedQueue BlockingQueue ArrayBlockingQueue LinkedBlockingQueue PriorityBl ...
- django-bootstrap4|django 加载popper.min.js失败
1.现象 2.解决过程 2.1.右键查看网页源代码 在浏览器地址栏打开popper.min.js对应的URL,发现无法打开,这个地址是国外的,需要找一个可访问的地址替换. 2.2.找到URL在djan ...
- vue 之this.$router.push、replace、go的区别
一.this.$router.push 说明:跳转到指定URL,向history栈添加一个新的记录,点击后退会返回至上一个页面 使用: this.$router.push('/index') this ...
- idea配置代码注释模板
从eclipse换成idea后,有点不习惯,其中之一就是代码注释,感觉不如eclipse好用,下面是一些配置方法,配完之后差不多能实现eclipse的效果. 1.以配置Class的注释为例,其他文件的 ...
- 一周死磕fastreport ----ASP.NET (一)
https://blog.csdn.net/wuyuander/article/details/52692435 原文链接,点击跳转 首先是安装好FastReport .net: 然后在vs2012中 ...
- 6. Design Patterns with First-Class Functions
1. Refactoring Strategy 1.1 Classic Strategy from abc import ABC, abstractmethod from collections im ...
- Nexus Repository Manager OSS 2 配置阿里云私服做代理的坑
安装 搭建 Nexus 私服很简单,官网下载,解压: 使用管理员权限打开cmd: > cd nexus---bundle\nexus--\bin > nexus.bat install # ...
- java线程基础巩固---如何实现一个自己的显式锁Lock
拋出synchronized问题: 对于一个方法上了同锁如果被一个线程占有了,而假如该线程长时间工作,那其它线程不就只能傻傻的等着,而且是无限的等这线程工作完成了才能执行自己的任务,这里来演示一下这种 ...
- 长期专业版 mac pycharm
https://www.52pojie.cn/forum.php?mod=viewthread&tid=757722&tdsourcetag=s_pcqq_aiomsg
- C#Socket编程(一)简介
一.TCP与UDP简介 https://blog.csdn.net/subin_iecas/article/details/80289513 二.单播.多播.广播 https://blog.csdn. ...