我是JS和Backbone的新手
这两者有什么区别?
TestModel = new Backbone.Model({ title: "test title" })
TestModel = Backbone.Model.extend({ title: "test title" })
Run Code Online (Sandbox Code Playgroud) 我想在jquery.center.jsMeteor应用程序中添加一个JavaScript前端插件.
如果我把它放在我的app/目录中并刷新页面,我会收到此错误:
你的应用程序崩溃了.这是最新的日志.
node.js:201
throw e; // process.nextTick错误,或第一次勾选时出现'error'事件
^
ReferenceError:jQuery未定义
在app/jquery.center.js:43:1
atUsers/crapthings/Desktop /app/ .meteor/local/build /server/server.js:111:21
在Function的Array.forEach(native)
.(
/Users/crapthings/Desktop/app/.meteor/local/build/server/underscore.js:76:11)/Users/crapthings/Desktop/app/.meteor/local/build/server/server.js: 97:7
退出代码:1
您的应用程序崩溃了.等待文件更改.
他们做同样的事情吗?
我应该在客户端内使用哪一个?
if ( Meteor.is_client ) {
Meteor.startup(function () {
// my code here
});
}
Run Code Online (Sandbox Code Playgroud)
要么
if ( Meteor.is_client ) {
$(function() {
// my code here
});
}
Run Code Online (Sandbox Code Playgroud) 这到底是做什么的?
pageProps = await Component.getInitialProps(ctx)
看起来“pageProps”这只是一个空对象
import App, {Container} from 'next/app'
import React from 'react'
export default class MyApp extends App {
static async getInitialProps ({ Component, router, ctx }) {
let pageProps = {}
if (Component.getInitialProps) {
pageProps = await Component.getInitialProps(ctx)
}
return {pageProps}
}
render () {
const {Component, pageProps} = this.props
return <Container>
<Component {...pageProps} />
</Container>
}
}
Run Code Online (Sandbox Code Playgroud) 我搜索并找到了
_suppress_initial: true
Run Code Online (Sandbox Code Playgroud)
但它不适用于0.54
我想观察一些像Orders Collection这样的集合.
如果我有大订单,当新订单添加,我想使用观察来更新另一个集合.
我没有把观察放到Meteor.publish如果我不停止观察,如果我在服务器运行期间一直保持观察,这会减慢服务器的速度吗?
if Meteor.isServer
obOrders = Orders.find({}).observe # when server restart does this slow down performance ?
_suppress_initial: true # doesnt work
added: (order) ->
console.log order # still add exist documents
if Date.now() - order.timestamp < 500
console.log order # update another one
Run Code Online (Sandbox Code Playgroud)
或者我应该限制Orders.find {},限制:50并按时间戳排序以观察最新文档?
把观察服务器Meteor.startup或Meteor.publish放到那两个条件之间有什么不同?
如果我把它放入Meteor.startup这是否意味着我做一个单身观察?
我如何使用{{#isolate}}?
如果我创建一个包含一堆模板的页面,例如:
{{> page1}}
<template name="template1">reactive source1</template>
<template name="template2">reactive source2</template>
<template name="template3">reactive source3</template>
<template name="template4">reactive source4</template>
<template name="template5">reactive source5</template>
<template name="page1">
{{> template1}}
{{> template2}}
{{> template3}}
{{> template4}}
{{> template5}}
</template>
Run Code Online (Sandbox Code Playgroud)
如果每个模板都有更新的内容,那么每次都会重新呈现整个页面吗?我如何阻止这种情况发生?
我应该isolate在这种情况下使用吗?
如果我将任何帮助器绑定到这些模板,例如:
Template.template1.rendered = ->
console.log 'rendered at: ' + new Date().getTime()
Run Code Online (Sandbox Code Playgroud)
它会呈现至少5次,因为我有5个反应源.如果它们中的每一个都包含一个反应列表,它将呈现docs.length次.
我无法控制单个模板实例.
抱歉我的英语.
这是我之前在GitHub上发布的与此相关的问题:https://github.com/meteor/meteor/issues/435
喜欢这些插件
https://github.com/ArchieGoodwin/SilentShot
https://github.com/alongubkin/phonertc
他们没有tarball网址
cordova plugin add https://github.com/alongubkin/phonertc.git
Run Code Online (Sandbox Code Playgroud)
我该如何添加这样的插件?
meteor add cordova:@https://github.com/alongubkin/phonertc.git
Run Code Online (Sandbox Code Playgroud) 框架在这里 http://luracast.com/products/restler/
我正在使用restler作为我的工作的restful api,当我使用骨干模型保存到url时,它使用'HTTP PUT'请求方法发送和更新我的数据作为json,我想得到我的回复推杆......
如果它是我可以使用的HTTP POST请求方法
// to getting content from a POST
$post_data = json_decode(file_get_contents('php://input'), true);
Run Code Online (Sandbox Code Playgroud)
获取我的内容,但无法从HTTP PUT获取任何内容
// can't get anything from a PUT
function putpatients($id) {
$post_data = file_get_contents('php://input');
$post_data = json_decode($post_data, true);
echo $post_data['name'];
}
Run Code Online (Sandbox Code Playgroud)
浏览器响应空白
我如何以json的形式返回我的数据?
我已经阅读过mongoose文档了,我仍然无法弄清楚如何更新文档.
我使用mongoose的node,express和mongodb.
这是我的mongodb中的一个集合......
{ "title" : "this is a title",
"_id" : ObjectId( "4f7a92554ad893f322000004" ),
"nodes" : [
{ "title" : "this is node 1",
"_id" : ObjectId( "4f7a92554ad893f322000009" ) },
{ "title" : "this is node 2",
"_id" : ObjectId( "4f7a92554ad893f322000008" ) },
{ "title" : "this is node 3",
"_id" : ObjectId( "4f7a92554ad893f322000007" ) },
{ "title" : "this is node 4",
"_id" : ObjectId( "4f7a92554ad893f322000006" ) },
{ "title" : "this is node 5",
"_id" : ObjectId( …Run Code Online (Sandbox Code Playgroud) meteor ×5
javascript ×3
backbone.js ×2
constructor ×1
cordova ×1
express ×1
instance ×1
mongodb ×1
mongoose ×1
next.js ×1
node.js ×1
php ×1
rest ×1