【问题标题】:Vue pass parameter using handlebarsVue使用车把传递参数
【发布时间】:2021-03-19 10:19:22
【问题描述】:

您好,我使用带有 express 和车把以及 vue 2.6 的 nodejs 我想将 {{audioannotationid}} 传递给我的 vue 组件,但我不能, 我做错了什么? 对不起我的英语

这是我的edit.hbs

<div> Editar audio annnotations</div>
<div id="EditAudioannotations" idParametro="beowulfdgo" >    
 </div> 
{{audioannotationid}}

这是我的组件

<template>
  <div id="EditAudioannotations"  >Hola {{who}} 

{{valor}}
  </div> 
</template>
<script>
export default {
  name: 'EditAudioannotations',
   props:{idParametro:{
      type: String,
      default: '0',
    },},
  data() {
    return {
        who:"world",
        json: {},
        valor:"otro valor"
    };
  },
  methods: {

    },
    beforeMount() {
    },
  
};
</script>

<style></style>

这是我的 index.js

if(window.location.pathname.match(/\/audioannotations\/edit\//)){
    // window.Vue = Vue
    Vue.use(VueAxios, axios);
    Vue.component("EditAudioannotations", EditAudioannotations);
    window.vm = new Vue({
      el: '#EditAudioannotations',
      render: h => h(EditAudioannotations)

    })
}

这个结果

【问题讨论】:

标签: node.js vue.js handlebars.js


【解决方案1】:

我解决了从url获取id因为我不使用routex,在vue中添加这个方法

 created() {
    var currentUrl = window.location.pathname;
        this.ruta=currentUrl  
        //console.log(currentUrl);
        var ultimoSlash = this.ruta.lastIndexOf("/"); 
        this.ruta=this.ruta.substring(ultimoSlash+1)
  },

【讨论】:

    猜你喜欢
    • 2013-08-14
    • 2013-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-17
    • 2013-03-08
    相关资源
    最近更新 更多