由于业务需求,将列表展示数据定义为一个子组件plan,然后父主键的for循环中调用,类似于vue官方的todo实例,但是我的子组件中,定义查看按钮,希望点击后展示对话框,这里的对话框是iview中的组件Model,我自定义了组件Model样式,又封装了一个组件,放到了原来子组件plan中,但是并没有作用。为了进一步验证,我直接把Model组件拿到了我的plan组件中使用,但是还是没有作用。plan组件中大概是这个样子(我有定义数据,只是没展示,包括这model1=true):
<template>
<div>
<Row type="flex" justify="center" align="middle">
<Col span="2"><input type="checkbox" @change="toggle(plan.id)" :checked="isDone"></Col>
<Col span="10"><del v-if="isDone">{{plan.title}}</del><span v-else>{{plan.title}}</span></Col>
<Col span="8">{{plan.create_time}}</Col>
<Col span="2"><Icon @click="showcontent" type="md-eye" /></Col>
<Col span="2"><Icon type="md-trash" /></Col>
</Row>
<content :model1="model"></content>
<Modal v-model="modal1" width="360">
<p slot="header" style="color:#f60;text-align:center">
<Icon type="ios-information-circle"></Icon>
<span>Delete confirmation</span>
</p>
<div style="text-align:center">
<p>After this task is deleted, the downstream 10 tasks will not be implemented.</p>
<p>Will you delete it?</p>
</div>
<div slot="footer">
<Button type="error" size="large">Delete</Button>
</div>
</Modal>
</div>
</template>
此时我又想到了,我的父组件用了iview中的抽屉Drawer,也就是通过按钮点击显示抽屉,抽屉中显示子组件数据,此时子组件的数据可以展示出来,但是这个Model不能展示,是不是和我的Drawer有关呢??展示了Drawer使用了遮罩层,是不是再利用Model就不可以了呢,有什么解决办法么??
最后附上我的父组件使用plan的过程代码:
<Drawer width="300" title="今日计划" placement="left" :closable="false" v-model="value2">
<Row type="flex" align="middle">
<Col span="24" style="height: 45px" v-for="(plan,index) in today_plan" :key="index">
<plans :plan="plan"></plans>
</Col>
</Row>
</Drawer>