1

I am trying to create a simple vueJs project, and compile it with thethe help of webpack/babel. However upon running npm run dev to compile the project and start the vue server, I am getting that compilation of the Select.vue template has failed(the Select.vue which gets installed upon installing vue-strap), below is the exact error that is loading up on my local port:

Failed to compile.

./node_modules/vue-loader/lib/template-compiler?{"id":"data-v-5f7db264","hasScoped":true,"buble":{"transforms":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./node_modules/vue-strap/src/Select.vue
(Emitted value instead of an instance of Error) 
  Error compiling template:

  <div v-el:select :class="classes">
    <div class="form-control dropdown-toggle"
      :disabled="disabled || !hasParent"
      :readonly="readonly"
      @click="toggle()"
      @keyup.esc="show = false"
    >
      <span class="btn-content" v-html="loading ? text.loading : showPlaceholder || selected"></span>
      <span v-if="clearButton&&values.length" class="close" @click="clear()">&times;</span>
    </div>
    <select v-el:sel v-model="value" v-show="show" name="{{name}}" class="secret" :multiple="multiple" :required="required" :readonly="readonly" :disabled="disabled">
      <option v-if="required" value=""></option>
      <option v-for="option in options" :value="option[optionsValue]||option">{{ option[optionsLabel]||option }}</option>
    </select>
    <ul class="dropdown-menu">
      <template v-if="options.length">
        <li v-if="canSearch" class="bs-searchbox">
          <input type="text" placeholder="{{searchText||text.search}}" class="form-control" autocomplete="off"
            v-el:search
            v-model="searchValue"
            @keyup.esc="show = false"
          />
          <span v-show="searchValue" class="close" @click="clearSearch">&times;</span>
        </li>
        <li v-if="required&&!clearButton"><a @mousedown.prevent="clear() && blur()">{{ placeholder || text.notSelected }}</a></li>
        <li v-for="option in options | filterBy searchValue" :id="option[optionsValue]||option">
          <a @mousedown.prevent="select(option[optionsValue],option)">
            <span v-html="option[optionsLabel]||option"></span>
            <span class="glyphicon glyphicon-ok check-mark" v-show="isSelected(option[optionsValue])"></span>
          </a>
        </li>
      </template>
      <slot></slot>
      <div v-if="showNotify && !closeOnSelect" class="notify in" transition="fadein">{{limitText}}</div>
    </ul>
    <div v-if="showNotify && closeOnSelect" class="notify out" transition="fadein"><div>{{limitText}}</div></div>
  </div>

  - name="{{name}}": Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of <div id="{{ val }}">, use <div :id="val">.
  - placeholder="{{searchText||text.search}}": Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of <div id="{{ val }}">, use <div :id="val">.
  - invalid expression: Unexpected identifier in

    options | filterBy searchValue

  Raw expression: v-for="option in options | filterBy searchValue"


 @ ./node_modules/vue-strap/src/Select.vue 11:0-220
 @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/App.vue
 @ ./src/App.vue
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

I am also attaching my main.js and App.vue file, into which I am calling the Select.vue component:

main.js:

import Vue from 'vue'
import App from './App.vue'

new Vue({
  el: '#app',
  render: h => h(App)
})

App.vue

<template>
    <div>
        <app-header></app-header>
        <v-select v-model="selected" :options="['Vue.js','React']"></v-select>
        <app-footer></app-footer>
    </div>
</template>

<script>
import Header from './components/header.vue'
import select from '../node_modules/vue-strap/src/Select.vue'
import Footer from './components/footer.vue'
export default {
    components: {
        'app-header': Header,
        'app-footer': Footer,
        'v-select': select,
    },
    data() {
      return {

      }
    },
}
</script>

<style scoped>

</style>

I wonder why I am getting this error. I originally had this error in another project too, but let it go because I thought it might be due to the old versions of dependencies that I was using there. But in this project I am using the latest ones, still it is not compiling. Also, the header and footer are working fine, no problem in them. Any help is appreciated. Thanks.

DHRUV KAUSHAL
  • 127
  • 10
  • i think its from vue 1.x ? – Estradiaz Feb 05 '20 at 15:59
  • Hi Estradiaz. It's vue 2.9. I'm sorry, but I fail to understand how v-for is related to my question. I am trying to build a dropdown using vue-select. The codepen here https://codepen.io/sagalbot/pen/NpwrQO has similar code, and is working fine there. I wonder what the problem is. – DHRUV KAUSHAL Feb 05 '20 at 16:15

2 Answers2

1

These errors explain it:

- name="{{name}}": Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of <div id="{{ val }}">, use <div :id="val">.
- placeholder="{{searchText||text.search}}": Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of <div id="{{ val }}">, use <div :id="val">.
- invalid expression: Unexpected identifier in

  options | filterBy searchValue

Raw expression: v-for="option in options | filterBy searchValue"
  1. replace name="{{name}}" with :name="name"

  2. replace placeholder="{{searchText||text.search}}" with :placeholder="searchText || text.search"

  3. filterBy is deprecated - try replacing what you're iterating over with a computed method

tony19
  • 125,647
  • 18
  • 229
  • 307
willanderson
  • 1,458
  • 12
  • 13
  • Hi willianderson. Thank you for looking into this. The errors are gone, but the v-select is not showing up on my html. Any idea why? – DHRUV KAUSHAL Feb 05 '20 at 16:44
0

From what you say and the code shown in the error, you are using this library: https://github.com/yuche/vue-strap

This library is not mantained anymore and more importantly not compatible with Vue 2.9 that you are apparently using.

You can try to use this alternative fork that should be compatible with Vue 2, but keep in mind that you may need to change your codebase.

gere
  • 1,600
  • 1
  • 12
  • 19
  • Hi gere. Thank you for looking into this. I didn't know that vue-strap was not supported with Vue 2.9. But I fail to understand why upon creating a new project with vue-cli, the package.json contains vue-strap? Shouldn't they have removed it if it is no longer supported? – DHRUV KAUSHAL Feb 05 '20 at 16:50
  • I tried using the alternate vue-strap, but now I am facing these errors: https://stackoverflow.com/questions/60080825/v-select-component-not-loading-into-html?noredirect=1#comment106261442_60080825 . – DHRUV KAUSHAL Feb 05 '20 at 18:27