我陷入了困境.我收到这样的错误.
compiler.es5.js:1694 Uncaught Error: Unexpected value 'LoginComponent' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@Component annotation.
at syntaxError (compiler.es5.js:1694)
at compiler.es5.js:15595
at Array.forEach (<anonymous>)
at CompileMetadataResolver.webpackJsonp.../../../compiler/@angular/compiler.es5.js.CompileMetadataResolver.getNgModuleMetadata (compiler.es5.js:15577)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._loadModules (compiler.es5.js:26965)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler._compileModuleAndComponents (compiler.es5.js:26938)
at JitCompiler.webpackJsonp.../../../compiler/@angular/compiler.es5.js.JitCompiler.compileModuleAsync (compiler.es5.js:26867)
at PlatformRef_.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_._bootstrapModuleWithZone (core.es5.js:4536)
at PlatformRef_.webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_.bootstrapModule (core.es5.js:4522)
at Object.../../../../../src/main.ts (main.ts:11)
Run Code Online (Sandbox Code Playgroud)
我的登录组件看起来像这样
import { Component } from '@angular/Core';
@Component({
selector:'login-component',
templateUrl:'./login.component.html'
})
export class LoginComponent{}
Run Code Online (Sandbox Code Playgroud)
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import …Run Code Online (Sandbox Code Playgroud) 我想要一个使用HTML5的滑块,如下所示:
我可以在哪里显示价值.我试过以下代码:
<input type=range min=0 max=100 value=50 step=1 list=tickmarks>
<datalist id=tickmarks>
<option value="0 to 20">0</option>
<option>20</option>
<option>40</option>
<option>60</option>
<option>80</option>
<option>100</option>
</datalist>
Run Code Online (Sandbox Code Playgroud)
但似乎没有任何效果.任何的想法?
我刚接触webpack并做出反应,只是通过文档并创建了一个工作示例.不幸的是我卡住了,无法继续.问题是没有生成捆绑文件.我创建的文件是
的package.json
{
"name": "rohith",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server"
},
"author": "",
"license": "ISC",
"dependencies": {
"react": "^15.4.1",
"react-dom": "^15.4.1",
"webpack": "^1.13.3",
"webpack-dev-server": "^1.16.2"
}
}
Run Code Online (Sandbox Code Playgroud)
webpack.config.js
module.export = {
entry : './main.js',
output : {
path : './',
filename : 'index.js'
},
devServer : {
inline : true,
port : 3333
},
module : {
loaders : [
{
test : /\.js$/,
exclude : /node_modules/,
loader : 'babel',
query : {
presets : …Run Code Online (Sandbox Code Playgroud) 我是 React 和 Redux 的新手,我实际上是在创建自己的代码,但是我在无状态组件中遇到了路由器之类的东西。
所以,实际上我需要使用 this.props.history.push('/somepath') 路由到一个组件。这不会发生在无状态组件中。
我的无状态组件是
import React from "react"; // eslint-disable-line no-unused-vars
import "bootstrap/dist/css/bootstrap.min.css";
import "./header.css";
const Header = () => ({
handleAuthor() {
this.props.history('/somepath')// this is not working
},
render(){
return (
<div className = "header">
<h1 onClick = {this.handleAuthor.bind(this)}>{this.props.headerText}</h1>
</div>
);
}
});
export default Header;
Run Code Online (Sandbox Code Playgroud)
我在另一个无状态组件中调用它,比如 mainlayout
import React from "react"; // eslint-disable-line no-unused-vars
import Header from "../header/Header"; // eslint-disable-line no-unused-vars
import Footer from "../footer/Footer"; // eslint-disable-line no-unused-vars
import "./mainLayout.css";
const MainLayout = …Run Code Online (Sandbox Code Playgroud) 我想把一个字符串分成两行,但这行不应该分成两行,一半是一个字.我怎样才能做到这一点?
字符串格式如下:
var words="value.eight.seven.six.five.four.three"
Run Code Online (Sandbox Code Playgroud)
预期产出是:
"value.eight.seven.
six.five.four.three"
Run Code Online (Sandbox Code Playgroud) 我在这里遇到问题.这里有两个div"div1"和"div2".这里我想根据"div2"宽度调整"div1"宽度.我的要求是不应该为"div1"包含scrollBar的宽度,即我应该设置"div1"的高度,不包括"div2"中scrollBar的宽度.我想要一个jquery函数来查找宽度并减小"div1"的宽度.样本要求如下所示
<div class="div1"></div>
<div class="div2">HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello</div>
Run Code Online (Sandbox Code Playgroud)
.div1
{
width:100px;
height:100px;
border:1px solid black;
}
.div2
{
width:100px;
height:300px;
border:1px solid black;
overflow:auto;
word-break:break-all;
}
Run Code Online (Sandbox Code Playgroud)

小提琴演示就在这里
我是打字稿新手,处于学习阶段。我正在尝试创建一个泛型来强制执行以下条件
考虑我有一个空对象
const data = {}
Run Code Online (Sandbox Code Playgroud)
我需要创建一个通用的来检查以下条件
检查是否是一个对象,如果是,则检查里面是否有数据,否则返回 false
提前致谢