【问题标题】:How to remove some content after the window opens in Nuxt.js? Is it possible?在 Nuxt.js 中打开窗口后如何删除一些内容?是否可以?
【发布时间】:2021-09-30 05:14:23
【问题描述】:
<template>
    <div>
        <Acomponent />
        <Bcomponent />
        <div @click="openWindow()">hellow</div>
    </div>
</template>

<script>
export default {
    data() {
        return {}
    },
    methods: {
        openWindow() {
            const width = '1000'
            const height = '600'

            const left = Math.ceil((window.screen.width - width) / 2)
            const top = Math.ceil((window.screen.height - height) / 2)
            window.open(location.href, `width=${width}, height=${height}, left=${left}, top=${top}, resizable=yes, scrollbars=yes`)
        },
    },
}
</script>

希望新窗口打开后,组件A和B不会出现在新窗口中。有什么办法吗?

【问题讨论】:

    标签: vue.js nuxt.js


    【解决方案1】:

    是的,在data中新建一个属性,默认为true,在方法openWindow()中,将该属性设置为false。

    在A和B组件中,放入v-if="this.yourattribute"。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-24
      • 1970-01-01
      • 2010-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多