如何在 div 中打开 element-ui 抽屉而不是 window

How to open a element-ui drawer in a div as opposed to window

我试图让一个抽屉在 div 中弹出,而不是使用完整可用的 window。

var Main = {
    data() {
      return {
        drawer: false,
        direction: 'rtl',
      };
    }
  };
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')
@import url("//unpkg.com/element-ui@2.13.2/lib/theme-chalk/index.css");

.drawer-container{
  height: 600px;
  width: 600px;
  border: 1px solid red;
}
.drawer{
  height: 100%;
}
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/element-ui@2.13.2/lib/index.js"></script>
<div id="app">
<el-radio-group v-model="direction">
  <el-radio label="ltr">left to right</el-radio>
  <el-radio label="rtl">right to left</el-radio>
  <el-radio label="ttb">top to bottom</el-radio>
  <el-radio label="btt">bottom to top</el-radio>
</el-radio-group>

<el-button @click="drawer = true" type="primary" style="margin-left: 16px;">
  open
</el-button>
<div class="drawer-container">
  <el-drawer
    class="drawer"
    title="I am the title"
    :visible.sync="drawer"
    :direction="direction">
    <span>Hi, there!</span>
  </el-drawer>
  </div>
</div>

我遇到的问题是抽屉似乎完全不关心它 parents css 是什么。有人知道改变这个的方法吗?

事实证明这就像添加 position: relative

一样简单

var Main = {
    data() {
      return {
        drawer: false,
        direction: 'rtl',
      };
    }
  };
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')
@import url("//unpkg.com/element-ui@2.13.2/lib/theme-chalk/index.css");

.drawer-container{
  height: 600px;
  width: 600px;
  border: 1px solid red;
}
.drawer{
  position: relative;
  height: 100%;
}
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/element-ui@2.13.2/lib/index.js"></script>
<div id="app">
<el-radio-group v-model="direction">
  <el-radio label="ltr">left to right</el-radio>
  <el-radio label="rtl">right to left</el-radio>
  <el-radio label="ttb">top to bottom</el-radio>
  <el-radio label="btt">bottom to top</el-radio>
</el-radio-group>

<el-button @click="drawer = true" type="primary" style="margin-left: 16px;">
  open
</el-button>
<div class="drawer-container">
  <el-drawer
    class="drawer"
    title="I am the title"
    :visible.sync="drawer"
    :direction="direction">
    <span>Hi, there!</span>
  </el-drawer>
  </div>
</div>