画面サイズに合わせて要素を消してくれるVue.jsライブラリ「vue-not-visible」

by kabanoki

HTML

<div id="app">
  <div v-not-visible="'tablet'" v-on:click="show('tablet')">
      You screen more than tablet > 768
  </div>
  <div v-not-visible="'mobile'" v-on:click="show('mobile')">
      You screen more than mobile > 425
  </div>
  <div v-not-visible="'tablet_landscape'" v-on:click="show('tablet_landscape')">
      You screen more than tablet_landscape > 1024
  </div>
  <div v-not-visible="'desktop'" v-on:click="show('desktop')">
      You screen more than desktop > 1200
  </div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue-not-visible.min.js"></script>

CSS

body {
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
}

Vue

const vueNotVisible  = window['vueNotVisible'].default;
Vue.use(vueNotVisible) 
new Vue({
  el: '#app',
  methods: {
    show(str) {
      alert(str);
    }
  }
});