首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >meteor - lukemadera:autoform-googleplace

meteor - lukemadera:autoform-googleplace
EN

Stack Overflow用户
提问于 2016-02-29 11:06:42
回答 1查看 59关注 0票数 0

我已经安装了lukemadera:autoform-googleplace包,并遵循了使用说明。当我运行应用程序时,address字段不会在我键入时自动填充。我得到一个错误在控制台(Exception in template helper: ReferenceError: EJSON is not defined)可以有人告诉我,我错过了什么。

路径:Layout.html

代码语言:javascript
复制
<head>
  <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places"></script>  
</head>

路径:Schema.js

代码语言:javascript
复制
Schema.Address = new SimpleSchema({
    fullAddress: {
        type: String
    },
    lat: {
        type: Number,
        decimal: true
    },
    lng: {
        type: Number,
        decimal: true
    },
    geometry: {
        type: Object,
        blackbox: true
    },
    placeId: {
        type: String
    },
    street: {
        type: String,
        max: 100
    },
    city: {
        type: String,
        max: 50
    },
    state: {
        type: String,
        regEx: /^A[LKSZRAEP]|C[AOT]|D[EC]|F[LM]|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY]$/
    },
    zip: {
        type: String,
        regEx: /^[0-9]{5}$/
    },
    country: {
        type: String
    }
});

Schema.UserProfile = new SimpleSchema({
    address: {
        type: Schema.Address,
        optional: true
    }
});

路径:personalDetails.js

代码语言:javascript
复制
<template name="personalDetails">
{{#autoForm collection="Meteor.users" id="candidateProfile" doc=currentUser type="update"}}

    {{> afQuickField name="profile.address" type="googleplace" opts=optsGoogleplace}}

{{/autoForm}}
</template>

路径:personalDetails.js

代码语言:javascript
复制
Template.personalDetails.helpers({
  optsGoogleplace: function() {
    return {
      // type: 'googleUI',
      // stopTimeoutOnKeyup: false,
      // googleOptions: {
      //   componentRestrictions: { country:'us' }
      // }
    }
  }
});
EN

回答 1

Stack Overflow用户

发布于 2016-02-29 13:07:53

仅供参考,以防其他人遇到此错误,您需要安装ejson

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35691296

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档