小编Geo*_*nos的帖子

使用Meteor.methods和Meteor.call

我有以下服务器代码:

Meteor.startup(function () {
  Meteor.publish("AllMessages", function() {
    lists._ensureIndex( { location : "2d" } );
    return lists.find();
  });
});

Meteor.methods({
  getListsWithinBounds: function(bounds) {
    lists._ensureIndex( { location : "2d" } );
    return lists.find( { "location": { "$within": { "$box": [ [bounds.bottomLeftLng, bounds.bottomLeftLat] , [bounds.topRightLng, bounds.topRightLat] ] } } } );
  }
});
Run Code Online (Sandbox Code Playgroud)

和这个客户端代码:

Meteor.startup(function () {
  map = L.map('map_canvas').locate({setView: true, maxZoom: 21});
  L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
      attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
  }).addTo(map);
    bounds = {};    
    map.on('locationfound', function(e){ 
      bounds.bottomLeftLat = map.getBounds()._southWest.lat;
      bounds.bottomLeftLng = map.getBounds()._southWest.lng;
      bounds.topRightLat …
Run Code Online (Sandbox Code Playgroud)

javascript meteor

7
推荐指数
1
解决办法
2787
查看次数

Meteor中的服务器端数据验证

我的客户端文件中有一个表单和一个提交函数:

function submitme () {
    var message = $('#daform').serializeJSON();
    message.owner = Meteor.user().username;
    if(!message.description || !message.location.lat || !message.location.lng || !message.mysex || !message.yoursex) {
      return;          
      }
      else
      {
          lists.insert(message);
          console.log("Submitted!");
          $('#daform')[0].reset();
      }
}
Run Code Online (Sandbox Code Playgroud)

这很好用,虽然 - 它的客户端验证=>不安全.

如何在我的服务器文件中实施"备份"验证检查?(+红利问题:如何设置计时器,以便在您提交后需要等待X秒再重新提交?)

javascript validation backend meteor

6
推荐指数
1
解决办法
3081
查看次数

Meteor Accounts - 登录表单更改HTML删除下拉列表JS

如何修改Meteor的帐户-ui来更改所呈现的类和html标签,而无需重写所有帐户-ui逻辑?例如,我想删除" 下拉 "行为,只是直接在我的页面中显示表单.我读了这个答案,但它没有详细说明 - 它只是删除了默认的CSS.我想深入一点..

javascript meteor

6
推荐指数
2
解决办法
4899
查看次数

Flex方向列但两个孩子彼此相邻,桌面顺序不同

这是响应式设计的一部分,其中布局flex-direction: row用于桌面,并且必须flex-direction: column用于移动.但在两个元件onethree必须是彼此相邻,而不是在彼此的顶部上.(你不能将它们单独放在容器中,因为这会破坏桌面布局).

有没有办法用Flexbox实现这一目标?

.flex-container-desktop {
  display: flex;
  flex-direction: row;
}

.flex-container {
  display: flex;
  flex-direction: column;
}

.child {
  border: 1px solid red;
  margin-right: 10px;
  padding: 5px;
}

.two {
  order: 1;
}

.three {
  order: 2;
}

.one {
  order: 3;
}
Run Code Online (Sandbox Code Playgroud)
<b>Desktop</b>
<div class="flex-container-desktop">
  <div class="child one-desktop">
Child 1
  </div>
  <div class="child two-desktop">
Child 2
  </div>
  <div class="child three-desktop">
Child 3
  </div>
</div>
<hr>
<b>Mobile</b>
<div class="flex-container">
  <div class="child …
Run Code Online (Sandbox Code Playgroud)

html css flexbox responsive-design

6
推荐指数
1
解决办法
2398
查看次数

Supabase 返回空数组

我有一个消息表,位于 Supabase 的“公共”模式下。我试图从本地开发环境中获取所有行,但没有返回任何内容。

我想:

const response = await supabase.from('messages').select('*');
Run Code Online (Sandbox Code Playgroud)

我在 Supabase 日志中看到该请求:似乎回复了200OK

使用Sveltekit作为客户端,以及加载函数:

/** @type {import('./$types').PageLoad} */
export async function load() {
    const response = await supabase.from('messages').select('*');

    return { response };
}
Run Code Online (Sandbox Code Playgroud)

这是响应的日志:

{@debug} /src/routes/+page.svelte (6:1)
{
  data: {
    response: {
      error: null,
      data: [],
      count: null,
      status: 200,
      statusText: 'OK'
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

这是表格: 在此输入图像描述

postgresql svelte supabase

6
推荐指数
2
解决办法
4343
查看次数

掌握Meteor中的外部脚本加载顺序(谷歌地图)

我试图将一个谷歌地图(外部加载的脚本)添加到流星应用程序失败,我发现有两种问题:

  1. 如果我做了简单的事情并将主API脚本添加到我的<head></head>,那么它最后呈现.
  2. 当发生这种情况时,我不得不在我的模板中再次插入依赖于API的任何脚本<head>- 在主API脚本之后.(否则脚本抱怨他们没有看到API blabla ..)
  3. 然后实际函数调用的时间到了 - 现在把它放在<head>其余部分之后将不起作用.您需要使用Template.MyTemplate.rendered.

基本上我的问题是:

  • 处理这类事情的最简洁方法是什么?
  • 我可以使用其他一些变量/方法来确保我的HTML主要API文件在我的HTML中首先被调用吗?

javascript google-maps meteor

5
推荐指数
1
解决办法
5995
查看次数

全高度列背景颜色与Bootstrap网格

我知道机会很小,但你会如何实现如下布局,左边,中间和右边使用自举网格系统时有不同的背景颜色?我想列的布局是反对Bootstrap网格的想法,我是对的吗?

在此输入图像描述

这是一个在线用例网址.

CSS是用于跨度等的标准Bootstrap网格CSS.

我看了一些其他的SO Q和A,但我不想使用像JavaScript这样的东西......或IE7 +不支持的东西.

css twitter-bootstrap

5
推荐指数
2
解决办法
2万
查看次数

部署完整堆栈节点应用程序npm / package.json体系结构

我有一个包含后端(Node / Express)和前端客户端的存储库,如下所示:

??? build
??? config
??? coverage
?   ??? lcov-report
??? dist
?   ??? static
??? server (node/express server)
?   ??? coverage
?   ??? docs
|   ??? src
?   ??? etc
?   ??? package.json
|
??? src (Vue.js : client code)
?   ??? api
?   ??? assets
?   ??? components
?   ??? router
?   ??? store
??? static
??? package.json
Run Code Online (Sandbox Code Playgroud)

我有两个package.json文件,一个用于客户端,一个用于服务器。

  1. 我面临在诸如Heroku之类的服务上部署的问题,因为他们不希望在一个存储库中使用两个不同的npm软件包(我认为)。使用此设置如何部署到Heroku(或其他)?
  2. 在应用程序的两个部分都具有1个package.json文件会更明智吗?

在同一package.json中同时拥有前端和后端部分的优缺点是什么?

javascript heroku node.js npm

5
推荐指数
1
解决办法
1196
查看次数

如何更改<button>元素的font-family?

这是我唯一的CSS

@font-face {
  font-family: 'thefont';
  src: url('fonts/the-font.otf');
  font-style: normal;
}

body {
    font-family: 'thefont';
}
Run Code Online (Sandbox Code Playgroud)

当我做一个<button>Hi</button>字体最终成为-apple-system.

如果我实际分配了字体button,它将使字体出现.

有谁知道它为什么不影响身体及其内部的一切?

html css fonts

4
推荐指数
1
解决办法
1万
查看次数

Clicking list of elements on Cypress using a for loop without using each

I have a list of options/buttons which I need to be sure they're all set to a specific value. Every wrapper can have several buttons but the first one is always what I want set before my tests are run.

Therefore I need loop these wrappers and target the first child / button of each of them.

Typically this would be a case for each() but Cypress errors after the first click - the DOM re-renders and Cypress can't find …

html dom cypress

4
推荐指数
1
解决办法
7653
查看次数