Javascript 在编译时在vue js中传递道具

Javascript 在编译时在vue js中传递道具,javascript,vue.js,vuejs2,vue-component,Javascript,Vue.js,Vuejs2,Vue Component,我正在安装一个htmlform elment并进行重新编译。这需要一些道具。当我更新下面列出的道具时,控制台会抛出以下错误:- 看到这里的截图了吗 //这里有些进口货 导出默认值{ 道具:['pma_姿势','pma_密码','pma_用户名'], 数据:函数(){ 返回{ 域:“”, url:“”, dbs:[], 凭据:“” } }, 方法:{ //获取凭据的一些函数 getcredentials(){ 这个.popup(); }, 弹出窗口(){ //更新vue js抱怨的道具值 th

我正在安装一个htmlform elment并进行重新编译。这需要一些道具。当我更新下面列出的道具时,控制台会抛出以下错误:- 看到这里的截图了吗


//这里有些进口货
导出默认值{
道具:['pma_姿势','pma_密码','pma_用户名'],
数据:函数(){
返回{
域:“”,
url:“”,
dbs:[],
凭据:“”
}
},
方法:{
//获取凭据的一些函数
getcredentials(){
这个.popup();
},
弹出窗口(){
//更新vue js抱怨的道具值
this.pma_username=this.credentials.database;
this.pma_password=this.credentials.password;
this.pma_postrl=“URL”+this.credentials.database;
console.log(this.pma_username);//具有正确的值
this.compile('dbform',this.props);
$('#myform')。提交();
},
编译:函数(参考、道具){
var tmp=Vue.extend({
道具:道具,
模板:“”
});
新tmp().$mount(此.$refs[refs]);
}
}
}

您必须删除以下代码:

    //updating props value which vue js complains about  
 this.pma_username=this.credentials.database;
 this.pma_password=this.credentials.password;
 this.pma_posturl="URL"+this.credentials.database;

 console.log(this.pma_username); //has correct value
 this.compile('dbform',this.props);
并基于当前组件的
道具创建新对象,如下所示:

  let customprops={
                  'pma_posturl':"URL"+this.credentials.database,
                  'pma_password':this.credentials.password,
                 'pma_username': this.credentials.database
               }

   this.compile('dbform',customprops);

我把普洛斯达传递错了。这是有效的

compile: function(refs,props){
        var tmp = Vue.extend({
          props: ['pma_posturl','pma_password','pma_username'],
          template: '<form ......>........</form>'
        });
        new tmp({
        propsData: props
      }).$mount(this.$refs[refs]);

当我记录vm.$destory()时,我没有定义。我在这里做错了什么?

customprops对象确实具有正确的值。但是我的表单模板仍然得到空值。我的模板定义有问题吗?试着在模板的
mounted
钩子中如下操作:
mounted(){console.log(this.props)}
并查看结果
mounted(){console.log(this.props)}
==>未定义的
compile:function(refs,props){console.log(props)==>正确值new tmp().$mount(this.$refs[refs]);}
所以问题出在编译函数上,就像eric99所说的:“我不认为这样设置组件有什么意义”我的要求是我有一个输入字段,提交后,我获得一些凭据,然后在表单上发表文章,将我带到“新建”选项卡中的外部链接。我在运行时和之后在DOM中添加表单提交表单时,我会将其从DOM中删除。你们建议我如何前进。我不认为这样设置组件有什么意义。
compile: function(refs,props){
        var tmp = Vue.extend({
          props: ['pma_posturl','pma_password','pma_username'],
          template: '<form ......>........</form>'
        });
        new tmp({
        propsData: props
      }).$mount(this.$refs[refs]);
 // console.log(props) /* it has the latest value */
 var vm = new tmp({propsData: props}).$mount(this.$refs[refs]);
 $('#myform').submit();
  vm.$destroy();