首页 > 其他分享 >无涯教程-Meteor - Session

无涯教程-Meteor - Session

时间:2023-10-09 12:33:02浏览次数:37  
标签:教程 存储 myData 无涯 meteorApp Session Meteor

Session会话用于在用户使用应用程序时保存数据,用户离开应用程序后,该数据将被删除。

在本章中,无涯教程将学习如何设置Session会话对象,存储一些数据并返回该数据。

meteorApp.html

<head>
   <title>meteorApp</title>
</head>
 
<body>
   <div>
      {{> myTemplate}}
   </div>
</body>
 
<template name="myTemplate">
</template>

现在,无涯教程将使用 Session.set()方法在本地存储 myData ,设置方法后,无涯教程可以使用 Session.get()方法将其返回。

meteorApp.js

if (Meteor.isClient) {
  
   var myData={
      key1: "value1",
      key2: "value2"
   }

   Session.set('mySession', myData);

   var sessionDataToLog=Session.get('mySession');
   console.log(sessionDataToLog);
}

如果检查控制台,无涯教程将看到已存储的数据已记录。

Meteor Session Log

在下一章中,无涯教程将学习如何使用Session变量自动更新模板。

参考链接

https://www.learnfk.com/meteor/meteor-session.html

标签:教程,存储,myData,无涯,meteorApp,Session,Meteor
From: https://blog.51cto.com/u_14033984/7772287

相关文章

  • 无涯教程-Meteor - 模板(Template)
    Meteor模板正在使用三个顶级标签。前两个是head和body。这些标签执行与常规HTML相同的功能,第三个标签是template。这是无涯教程将HTML连接到JavaScript的地方。简单模板以下示例显示了它是如何工作的。无涯教程正在创建一个name=“myParagraph”属性的模板,无涯教程可以......
  • 无涯教程-Meteor - 应用实例
    在本章中,无涯教程将学习如何创建您的第一个Meteor应用程序。第1步-创建应用要创建该应用程序,无涯教程将在命令提示符窗口中运行meteorcreate命令。应用名称为meteorApp。C:\Users\username\Desktop\Meteor>meteorcreatemeteorApp第2步-运行应用无涯教程可以通过......
  • 无涯教程-Kotlin - 简介
    Kotlin是一种在Java虚拟机上运行的静态类型编程语言,它也可以被编译成为JavaScript源代码。它主要是由俄罗斯圣彼得堡的JetBrains开发团队所发展出来的编程语言,其名称来自于圣彼得堡附近的科特林岛。2012年1月,著名期刊《Dr.Dobb'sJournal》中Kotlin被认定为该月的最佳语言。虽然......
  • 无涯教程-Meteor - 环境设置
    在本章中,无涯教程将学习如何在Windows操作系统上安装Meteor,在开始使用Meteor之前,无涯教程需要NodeJS。NodeJS是Meteor开发所需的平台。如果您尚未准备好NodeJS环境设置,则可以查看无涯教程的NodeJS环境设置。安装Meteor从此页面下载官方Meteor安装程序。如果在安装过程中发......
  • 无涯教程-Meteor - 简介
    根据Meteor官方文件-Meteor是用于开发现代Web和移动应用程序的全堆栈JavaScript平台。Meteor包括一套用于构建连接客户端反应式应用程序的关键技术,一个构建工具以及来自Node.js和常规JavaScript社区的精选软件包。特征Web和Mobile   -Meteor提供了一个用于开发Web,An......
  • tomcat session cluster的实现
    #1.环境准备 IP主机名服务 10.0.0.150proxy.tan.comhttpd 10.0.0.160tomcat1.tan.comJDK8、tomcat8 10.0.0.170tomcat2.tan.comJDK8、tomcat8#2.在proxy主机配置httpd实现后端tomcat主机轮询[root@proxy~]#vim/etc/http......
  • 无涯教程-OC - Switches函数
    Switch用于在打开和关闭状态之间切换。Switches-重要属性onImageoffImageonSwitches-重要方法-(void)setOn:(BOOL)onanimated:(BOOL)animatedSwitches-自定义方法-(IBAction)switched:(id)sender{NSLog(@"Switchcurrentstate%@",mySwitch.on?@"On":......
  • 无涯教程-OC - Pickers函数
    Pickers包含一个旋转的可滚动视图,该视图用于从项目列表中选择一个值。Pickers-重要属性delegatedataSourcePickers-重要方法-(void)reloadAllComponents-(void)reloadComponent:(NSInteger)component-(NSInteger)selectedRowInComponent:(NSInteger)component-(v......
  • sessionStorage的setItem和getItem使用
    一、vue文件使用sessionStorage:(简单存值取值)1.存储数据:sessionStorage.setItem('取得k的名字','要存储的值')vuesessionStorage.setItem('loadClaim','this.node')2.获取数据:sessionStorage.getItem('取得k的名字')vuesessionStorage.getItem......
  • 无涯教程-OC - Image View函数
    ImageView用于显示单个图像或动画序列。ImageView-重要属性imageHighlightingImageuserInteractionEnabledanimationImagesanimationRepeatCountImageView-重要方法-(id)initWithImage:(UIImage*)image-(id)initWithImage:(UIImage*)imagehighlightedIm......