我正在渲染一个帖子列表.对于每个帖子,我想渲染一个锚标签,其中post id作为href字符串的一部分.
render: function(){
return (
<ul>
{
this.props.posts.map(function(post){
return <li key={post.id}><a href='/posts/'{post.id}>{post.title}</a></li>
})
}
</ul>
);
Run Code Online (Sandbox Code Playgroud)
如何做到这一点,使每个岗位有HREF的/posts/1
,/posts/2
等等?
我有一个目录结构
projectName
| - bower_components/
| - public/
| - css
| - js
| - index.html
| - Gruntfile.js
| - package.json
| - bower.json
| - app.js
Run Code Online (Sandbox Code Playgroud)
我想启动我的应用程序并index.html
使用节点服务.所以app.js
我有:
var express = require('express');
var port = process.env.PORT || 3000;
var app = express();
app.configure(function(){
// Serve up content from public directory
app.use(express.static(__dirname + '/public'));
app.use(app.router);
app.use(express.logger());
});
app.listen(port, function(){
console.log('Express server listening on port ' + port);
});
Run Code Online (Sandbox Code Playgroud)
在index.html
我的底部:
<script src="../bower_components/jquery/jquery.js"></script>
<script src="../bower_components/d3/d3.js"></script> …
Run Code Online (Sandbox Code Playgroud) 我有一个组件与一些表单验证.这是一个多步骤结帐表格.下面的代码是第一步.我想验证用户输入了一些文本,将其名称存储在全局状态,然后发送到下一步.我正在使用vee-validate和vuex
<template>
<div>
<div class='field'>
<label class='label' for='name'>Name</label>
<div class="control has-icons-right">
<input name="name" v-model="name" v-validate="'required|alpha'" :class="{'input': true, 'is-danger': errors.has('name') }" type="text" placeholder="First and Last">
<span class="icon is-small is-right" v-if="errors.has('name')">
<i class="fa fa-warning"></i>
</span>
</div>
<p class="help is-danger" v-show="errors.has('name')">{{ errors.first('name') }}</p>
</div>
<div class="field pull-right">
<button class="button is-medium is-primary" type="submit" @click.prevent="nextStep">Next Step</button>
</div>
</div>
</template>
<script>
export default {
methods: {
nextStep(){
var self = this;
// from baianat/vee-validate
this.$validator.validateAll().then((result) => {
if (result) {
this.$store.dispatch('addContactInfoForOrder', self);
this.$store.dispatch('goToNextStep');
return; …
Run Code Online (Sandbox Code Playgroud) 这是一个很长的镜头,但有没有人见过这个错误?我试图使用express,angular和mongoDB添加'Transporters'.每当我访问由传输器控制器管理的页面时,我都会收到此错误:
Error: [ng:areq] http://errors.angularjs.org/1.2.12/ng/areq?p0=TransportersController&p1=not%20aNaNunction%2C%20got%20undefined
at Error (native)
at http://localhost:3000/lib/angular/angular.min.js:6:450
at tb (http://localhost:3000/lib/angular/angular.min.js:18:360)
at Pa (http://localhost:3000/lib/angular/angular.min.js:18:447)
at http://localhost:3000/lib/angular/angular.min.js:62:17
at http://localhost:3000/lib/angular/angular.min.js:49:43
at q (http://localhost:3000/lib/angular/angular.min.js:7:386)
at H (http://localhost:3000/lib/angular/angular.min.js:48:406)
at f (http://localhost:3000/lib/angular/angular.min.js:42:399)
at http://localhost:3000/lib/angular/angular.min.js:42:67
Run Code Online (Sandbox Code Playgroud)
传输器控制器如下所示:
'use strict';
angular.module('mean.transporters').controller('TransportersController', ['$scope', '$routeParams', '$location', 'Global', 'Transporters', function ($scope, $routeParams, $location, Global, Transporters) {
$scope.global = Global;
$scope.create = function() {
var transporter = new Transporters({
name: this.name,
natl_id: this.natl_id,
phone: this.phone
});
transporter.$save(function(response) {
$location.path('transporters/' + response._id);
});
this.title = '';
this.content = '';
};
$scope.remove = …
Run Code Online (Sandbox Code Playgroud) 我正在尝试为mongodb uni课程做作业.他们给了我们一些文件,说明是:
npm install mongodb
然后跑node app.js
由于某种原因,npm install不会创建node_modules目录,但我没有看到任何构建错误:
mongo-uni/hw1-2$ npm install mongodb
npm WARN package.json path@0.4.9 path is also the name of a node core module.
npm http GET https://registry.npmjs.org/mongodb
npm http 304 https://registry.npmjs.org/mongodb
npm http GET https://registry.npmjs.org/bson/0.2.5
npm http GET https://registry.npmjs.org/kerberos/0.0.3
npm http 304 https://registry.npmjs.org/kerberos/0.0.3
npm http 304 https://registry.npmjs.org/bson/0.2.5
> kerberos@0.0.3 install /home/jasonshark/node_modules/mongodb/node_modules/kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory `/home/jasonshark/node_modules/mongodb/node_modules/kerberos/build'
SOLINK_MODULE(target) Release/obj.target/kerberos.node
SOLINK_MODULE(target) Release/obj.target/kerberos.node: Finished
COPY Release/kerberos.node
make: Leaving directory `/home/jasonshark/node_modules/mongodb/node_modules/kerberos/build'
> …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将Laravel文件添加到Github存储库中.
我跑了
$ git clone https://github.com/laravel/laravel.git
文件在本地显示正常但在我推送到github时不显示:
提交显示:
如何将laravel文件添加到我的github仓库?另外,什么是子项目提交?
我用自耕农发电机写了一个角应用程序.它在开发中运行良好,但在我部署到heroku并访问特定页面后,我收到此错误:
Error: [$parse:lexerr] Lexer Error: Unexpected next character at columns 0-0 [\] in expression [\].
http://errors.angularjs.org/1.2.6/$parse/lexerr?p0=Unexpected%20nextharacter%20&p1=s%200-0%20%5B%5C%5D&p2=%5C
at http://ang-news.herokuapp.com/scripts/244c37f5.vendor.js:3:30474
at Zd.throwError (http://ang-news.herokuapp.com/scripts/244c37f5.vendor.js:6:14396)
at Zd.lex (http://ang-news.herokuapp.com/scripts/244c37f5.vendor.js:6:13696)
at $d.parse (http://ang-news.herokuapp.com/scripts/244c37f5.vendor.js:6:16445)
at http://ang-news.herokuapp.com/scripts/244c37f5.vendor.js:5:13197
at e.parseAs (http://ang-news.herokuapp.com/scripts/244c37f5.vendor.js:5:23401)
at Object.e.(anonymous function) [as parseAsResourceUrl] (http://ang-news.herokuapp.com/scripts/244c37f5.vendor.js:5:23604)
at http://ang-news.herokuapp.com/scripts/244c37f5.vendor.js:6:28873
at q (http://ang-news.herokuapp.com/scripts/244c37f5.vendor.js:4:23046)
at h (http://ang-news.herokuapp.com/scripts/244c37f5.vendor.js:4:19250)
Run Code Online (Sandbox Code Playgroud)
此描述表示当表达式出现词法错误时会发生错误.
那是什么,为什么它只出现在生产中?
我最近买了一台新机器,现在想从Github处理我的项目.我很好奇如何在我的本地机器上正确设置Postgres数据库.我有postgresql
,pgadmin3
并libpq-dev
安装在Ubuntu(12.04)上.
我拉下项目:
git clone https://github.com/thebenedict/cowsnhills.git
并运行:
bundle
.
当我跑:
rake db:create && rake db:schema:load
我收到此错误:
rake db:create && rake db:schema:load
FATAL: password authentication failed for user "cnh"
FATAL: password authentication failed for user "cnh"
....
Run Code Online (Sandbox Code Playgroud)
该config/database.yml
文件如下所示:
development:
adapter: postgresql
encoding: unicode
host: localhost
database: cnh_development
pool: 5
username: cnh
password: cnh
test:
adapter: postgresql
encoding: unicode
host: localhost
database: cnh_test
pool: 5
username: cnh
password: cnh
production:
adapter: postgresql
encoding: unicode
host: …
Run Code Online (Sandbox Code Playgroud) postgresql ubuntu ruby-on-rails rails-postgresql postgresql-9.1
我有一个组织的github页面,我想从第三方api调用数据,我需要一个身份验证令牌.我是否可以在公共回购中没有显示身份验证令牌的情况下发布此github页面?
我正在尝试将android平台添加到我的cordova项目,虽然我收到错误:
$ cordova platform add android -d
cordova library for "android" already exists. No need to download. Continuing.
Checking if platform "android" passes minimum requirements...
Checking Android requirements...
cordova library for "android" already exists. No need to download. Continuing.
Error: An error occurred while listing Android targets
at /home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/lib/check_reqs.js:83:29
at _rejected (/home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:808:24)
at /home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:752:41)
at /home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:574:44
at flush (/home/jasonshark/.cordova/lib/android/cordova/3.2.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Run Code Online (Sandbox Code Playgroud)
没有-d
它将是:
Checking Android requirements...
[Error: An error occurred while listing …
Run Code Online (Sandbox Code Playgroud) javascript ×3
angularjs ×2
github ×2
node.js ×2
ubuntu ×2
ajax ×1
android ×1
bower ×1
cordova ×1
express ×1
git ×1
github-pages ×1
mean-stack ×1
node-modules ×1
npm ×1
postgresql ×1
reactjs ×1
vue.js ×1
vuejs2 ×1
vuex ×1