【问题标题】:Meteor, ClientStorage- TypeError: Cannot read property 'has' of undefinedMeteor,ClientStorage-TypeError:无法读取未定义的属性“具有”
【发布时间】:2017-12-03 03:14:27
【问题描述】:

我正在像这样使用ostrio:cstorage 包(用于测试):

import { check } from 'meteor/check'
import { Meteor } from 'meteor/meteor'
import {Tasks} from './collections.js'
import { ClientStorage, clientStorage } from 'meteor/ostrio:cstorage';

Meteor.methods({
  'vote.check'(tipId) {
  //check(tipId, String);

  // we want to use a date with a 1-day granularity
  var startOfDay = new Date;
  startOfDay.setHours(0, 0, 0, 0);
  console.log("In vote.check:"+tipId);

  clientStorage.has('aaaa');
},

但我总是收到“TypeError: Cannot read property 'has' of undefined”——谁能告诉我为什么?我真的不知道。谢谢

【问题讨论】:

    标签: javascript meteor


    【解决方案1】:

    我认为你可以做到:

    ClientStorage.has('aaaa');
    

    小写版本定义了一个类;要使用它,您需要创建一个新变量。

    csCookies = new clientStorage('cookies');
    csCookies.has('aaaa');
    

    您不需要同时导入ClientStorageclientStorage。大写字母透明地处理 cookie/本地存储。

    【讨论】:

      猜你喜欢
      • 2015-07-10
      • 2018-03-02
      • 2019-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-29
      • 1970-01-01
      相关资源
      最近更新 更多