1. vue-container-query
**Totally based on [d6u/react-container-query](https://github.com/d6u/react-container-query).**
vue-container-query
Package: vue-container-query
Last modified: Mon, 23 May 2022 13:40:56 GMT
Version: 0.1.0
License: MIT
Downloads: 5,309

Install

npm install vue-container-query
yarn add vue-container-query

vue-container-query

Totally based on d6u/react-container-query.

Notice

The following documentation is also originated from d6u/react-container-query.

Your suggested to pay a visit to the repo react-container-query.

Installation

 npm i -D vue-container-query

API

<container-query :query="query" :initialSize="{ width, height } />

 <template>
  <container-query
    :query="query"
    v-model="params"
    @change="handleChange"
  >
    <pre class="app">{{ params }}</pre>
  </container-query>
</template>

<script>
import { ContainerQuery } from './'

const query = {
  'width-between-400-and-599': {
    minWidth: 400,
    maxWidth: 599
  },
  'width-larger-than-600': {
    minWidth: 600
  }
}

export default {
  components: { ContainerQuery },
  data () {
    return { query, params: {} }
  },
  methods: {
    handleChange () {}
  }
}
</script>

properties

  • props.children

    There should only be **one, and exactly one ** child component.

  • props.query

    "query" is key-value pairs where keys are the class names that will be applied to container element when all constraints are met. The values are the constraints.

  • props.initialSize (optional)

    initialSize is an object with optional width or height property. Because the limitation on how size is computed based on underlying element, in the initial rendering pass, we don't have the size info (because element must be in the DOM have a valid size). At this time initialSize will be used as the size of the element.

createContainerQueryMixin(query, initialSize)

 
<template>
  <pre class="app">{{ containerQuery }}</pre>
</template>

<script>
import { createContainerQueryMixin } from './'

const query = {
  'width-between-400-and-599': {
    minWidth: 400,
    maxWidth: 599
  },
  'width-larger-than-600': {
    minWidth: 600
  }
}

export default {
  mixins: [
    createContainerQueryMixin(query)
  ]
}
</script>

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin