我已经习惯了 node.js 中路由的工作方式,但是让我给你一个 socket.io 节点服务器的典型示例:
/**
* Created by root on 3/13/15.
*/
var multer = require('multer');
var express = require('express');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var cookieParser = require('socket.io-cookie-parser');
var moment = require('moment');
var mysql = require('mysql');
var users = [];
var message = "";
io.use(cookieParser());
io.on('connection', function (socket) {
var userDetails = {};
/*
Connection (after login)
*/
socket.on('userData', function (userDetails) {
users[userDetails.id] = socket;
userDetails = userDetails;
});
//Notification
socket.on('sendNotification', …Run Code Online (Sandbox Code Playgroud) 我使用Sendgrid制作了以下模板:
为了使用我的节点服务器发送此内容,我创建了以下模块:
/**
* Created by root on 6/6/16.
*/
var path = require('path'),
emailTemplates = require('email-templates'),
async = require("async"),
mailConfig = require('../config/email.json'),
templates = require('../config/emailTemplates.json'),
_ = require('lodash'),
sendgrid = require('sendgrid')(mailConfig.sendGridApiKey);
var mymailer = {};
/**
* Sends an email to either one or multiple users
* @param template_id (The id key of the template. Can be found in emailTemplates.json
* @param to String or Array
* @param from String
* @param subject String
* @param keyReplacer Array of …Run Code Online (Sandbox Code Playgroud) 我试图在我的绘图图表上创建一个 onclick 事件。根据文档,我创建了以下图表:
var graphDiv = document.getElementById('uniqueId');
Plotly.newPlot('uniqueId', charData, layout);
graphDiv.on('plotly_click', function (data) {
var i = 0;
})
Run Code Online (Sandbox Code Playgroud)
但是,当我运行它时,出现以下错误:
graphDiv.on is not a function
Run Code Online (Sandbox Code Playgroud)
那么谁能告诉我我做错了什么?
请注意,我也尝试过使用 jquery:
$('#uniqueId').on('plotly_click', function(){})
Run Code Online (Sandbox Code Playgroud)
这没有引发错误,但单击图表时未调用该函数。
小提琴:
我的控制器中有以下操作:
public function viewPost($id)
{
$current_post = forum_post::with('replies')->where('id', $id)->get();
return view('forumViewPost',['currentPost', $current_post]);
}
Run Code Online (Sandbox Code Playgroud)
然后我有以下观点:
@extends('layout.app')
@section('content')
<div class="container">
<div class="nk-gap-2"></div>
<ul class="nk-forum nk-forum-topic">
<li>
<div class="nk-forum-topic-author">
<img src="assets/images/avatar-2-sm.jpg" alt="Kurt Tucker">
<div class="nk-forum-topic-author-name" title="Kurt Tucker">
<a href="#">{{$currentPost->nickname}}</a>
</div>
<div class="nk-forum-topic-author-role">
Member
</div>
</div>
<div class="nk-forum-topic-content">
{{$currentPost->content}}
</div>
<div class="nk-forum-topic-footer">
<span class="nk-forum-topic-date">June 19,
2017</span> <span class="nk-forum-action-btn"><a href="#forum-reply" class="nk-anchor"> Reply</a></span>
<span class="nk-forum-action-btn"><a href="#"> Spam</a></span>
<span class="nk-forum-action-btn"><span class="nk-action-heart liked"><span class="num">1</span>
Like</span></span>
</div>
</li>
@foreach($currentPost->replies as $replies)
@endforeach
</ul>
</div>
@endsection
Run Code Online (Sandbox Code Playgroud)
现在当我跑这个.我收到以下错误:
Undefined variable: currentPost …Run Code Online (Sandbox Code Playgroud) 我正在尝试转储我的数据库。
由于我无法在这里详细介绍的原因,我无法使用“复制”功能。这意味着插入语句必须是“纯”插入。但是,我不确定如何在我的转储中反映这一点。
目前,这是我的转储命令:
pg_dump -U myUser --column-inserts --data-only -h localhost my_db> backup
Run Code Online (Sandbox Code Playgroud)
谁能告诉我如何在没有Copy函数的情况下获得插入语句?
所以我试图使用DatePicker,但是我得到了StaticInjectorError
这是我尝试过的:
import {Component} from '@angular/core';
import {TextService} from '@core/services/text/text.service';
import {Router} from '@angular/router';
import {FeaturePage} from '@feature/paths';
import {User} from '@core/classes/user';
import {DatePicker} from '@ionic-native/date-picker/ngx';
@Component({
selector: 'app-setup',
templateUrl: 'setup.page.html',
styleUrls: ['setup.page.scss'],
})
export class SetupPage {
user: User;
constructor(private textService: TextService, private router: Router, private datePicker: DatePicker) {
this.user = new User();
this.datePicker.show({
date: new Date(),
mode: 'date',
androidTheme: this.datePicker.ANDROID_THEMES.THEME_HOLO_DARK
}).then(
date => console.log('Got date: ', date),
err => console.log('Error occurred while getting date: ', …Run Code Online (Sandbox Code Playgroud) 是否有可能改变gritter?或者甚至更好地将它绑定到诸如span或div之类的元素?
我试过了:
$.gritter.add({
title: 'Dashboard',
text: 'Field updated!',
time: 2000,
position: 'center'
});
Run Code Online (Sandbox Code Playgroud)
(也尝试过buttom,top等)但位置保持不变
我有以下javascript:
$('#edit_category').on('click','#btn_save_category_name',function(){
currently_edit.text($('#txt_edit_category').val());
edit_category_name(currently_edit,current_category_id);
$('#edit_category').modal('hide')
})
function edit_category_name(name, id){
$.ajax({
type: 'POST',
url: '/Category/edit_team_category',
dataType: 'json',
data: {
request: 'ajax',
name: name,
id: id
},
success: function (data) {
}
});
}
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试这个时,我收到以下错误: called 'click' called on an object that does not implement interface HTMLElement.
但如果我评论功能线出来又称: edit_category_name(currently_edit,current_category_id);
一切正常.
谁能告诉我为什么会这样?
更新我的完整脚本
var mode = 'team';
var currently_edit = '';
var current_team_id = 0;
var current_category_id = 0;
jQuery(document).ready(function(){
//Main click function for Team (selection of team)
$('#team_wrapper').on('click', '.panel-heading', function () { …Run Code Online (Sandbox Code Playgroud) 我的数据库中有以下行:
'1', '1', '1', 'Hello world', 'Hello', '2014-01-14 17:33:34'
Run Code Online (Sandbox Code Playgroud)
现在我希望选择此行并仅从此时间戳中获取日期:
我尝试过以下方法:
SELECT title, FROM_UNIXTIME(timestamp,'%Y %D %M') AS MYDATE FROM Team_Note TN WHERE id = 1
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
SELECT title, DATE_FORMAT(FROM_UNIXTIME(`timestamp`), '%e %b %Y') AS MYDATE FROM Team_Note TN WHERE id = 1
Run Code Online (Sandbox Code Playgroud)
然而,这些只返回一个空结果(或者我得到Hello部分,但MYDATE为空)
我有以下设置:

现在我的文件看起来如下:
AGENTER_LISTE.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestNhibernate
{
public class AGENTER_LISTE
{
public virtual int ID { get; set; }
public virtual String INITIALER { get; set; }
public virtual String FORNAVN { get; set; }
public virtual String EFTERNAVN { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
AGENTER_LISTE.hbm.xml:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="TestNhibernate" namespace="TestNhibernate">
<class name="TestNhibernate.AGENTER_LISTE">
<id name="ID" column="ID">
<generator class="identity" />
</id>
<property name="INITIALER" />
<property name="FORNAVN" />
<property name="Efternavn" />
</class> …Run Code Online (Sandbox Code Playgroud)