Coder Social home page Coder Social logo

vue-simple-bem's Issues

classes are lost when used on a router-link component

I'm using v-bem on a router-link component from the Vue Router.

<router-link v-bem:link to="/demo">Top</router-link>

When the link is clicked, the v-bem class disappears. It's because router link is also adding/removing classes.

Maybe we can tie into other directive lifecycle hooks to keep the DOM classes in sync.

Block modifier problem

Great utility, so easy to use, thank you! But I found a possible issue—or something I did not understand…

I made this simple Vue 3 component (ReponsiveLayout.vue) :

<template>
  <div v-bem="`${props.columns}`">
    <slot />
  </div>
</template>

<script setup lang="ts">
interface Props {
  columns?: number
}
const props = withDefaults(defineProps<Props>(), {
  columns: 3
})
...
</script>

<script lang="ts">
// Required for vue-simple-bem (cannot infer block-level class without explicite declaration)
export default {
  name: 'ResponsiveLayout'
}
</script>

Using this component without any property set, I expected the <div> element to have two classes: responsive-layout responsive-layout--3

Instead I got: responsive-layout responsive-layout--0 (???)

I also tried this solution:

<template>
  <div v-bem="`cols-${props.columns}`">
    <slot />
  </div>
</template>
// (no changes below this line)

The expected result was: responsive-layout responsive-layout--cols-3

But I got: responsive-layout responsive-layout--0 responsive-layout--1 responsive-layout--2 responsive-layout--3 responsive-layout--4 responsive-layout--5 (???)

What am I doing wrong ? Or is it a real issue ?

vue-simple-bem@latest (2.0.0)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.