这是常见的目的,指向不发布页面的不匹配请求.
使用react-router v4制作它看起来像以前的版本,我希望这个示例在下面工作.链接工作正常,但我希望NotFound组件只调用未知的url请求; 但它总是在那里.
import {
BrowserRouter as Router,
Route,
Link
} from 'react-router-dom'
class Layout extends Component {
render() {
return (
<Router>
<div className="App">
<ul>
<li><Link to="/">Home</Link></li>
<li><Link to="/user">User</Link></li>
</ul>
<Route exact path="/" component={Home}/>
<Route path="/user" component={User}/>
<Route path="*" component={Notfound}/>
</div>
</Router>
);
}
}
Run Code Online (Sandbox Code Playgroud)
它自path="*"
代表所有请求和未发现的组件总是在那里,但我怎么能说隐藏这个组件的有效网址路径?
它直截了当的过程;
但是jsx编译器由于某种原因不允许它?
所以只有差异是桌子的位置.为什么jsx会干扰这个过程?为什么有必要?
我最近开始反应原生和跟随教程指南有2个选项一个是通过"create-react-native-app myproject"创建项目,另一个是"react-native init myproject".
第一个(create-react-native-app)只生成app.js而另一个生成index.android.js和index.ios.js ..
我知道他们在做同样的工作,但这里真正的不同之处是什么?我应该选择哪一个开始,哪一个更有用?
我已经设定了;
var calendar = $('#calendar').fullCalendar({
axisFormat: 'HH:mm',
timezone:false,
ignoreTimezone: true,...
Run Code Online (Sandbox Code Playgroud)
所以我希望它使用当前的本地时间设置但不是..当我在日历事件对象日期中选择一个时间是提前2小时..我认为它是因为我的时区是UTC + 2但我不希望它添加我想要的任何东西我在日历中选择..这里看起来如何..(我选择星期一下午23:30,但活动日期是:星期二01:30 AM)
我看到浏览器该对象(Moment)有一个属性_isUTC:true ..我认为这是我的问题,但我怎么能把它设置为false?
我在index.html(root)中有一个脚本文件引用; index.html的:
<script src="page1.js"></script>
<script src="assets/sliderfunctions.js"></script>
<script src="assets/js/custom.js"></script>
Run Code Online (Sandbox Code Playgroud)
这里不需要sliderfunctions.js,它包含一些关于滑块的特定功能,所以我把它带到slider.component.html文件,但是你猜它不能正常工作,因为我实际上从未加载到浏览器..
slider.component.ts:
import {Component,ViewEncapsulation} from '@angular/core';
@Component({
selector:'app-slider',
templateUrl:'../templates/slider.component.html'
})
export class SliderComponent{
constructor(){}
}
Run Code Online (Sandbox Code Playgroud)
slider.component.html:
<script src="page1.js"></script>
<script src="assets/sliderfunctions.js"></script>
<script src="assets/js/custom.js"></script>
Run Code Online (Sandbox Code Playgroud)
(我带了3个,因为脚本的顺序很重要)所以我想得到一个特定的点,我已经在网上搜索但是无法弄清楚如何在组件模板中添加脚本文件
我正在使用这个项目模板。我在 App.tsx 文件中的 App 类中设置了一个断点。下面共享配置。看起来没有什么问题,但即使“F5”也没有触发任何东西,它也不起作用。
我搜索了很多但找不到任何合适的解决方案.. launch.json:
"version": "0.2.0",
"configurations":
[
{
"args": [],
"cwd": "${workspaceRoot}",
"env": {
"NODE_ENV": "development"
},
"externalConsole": false,
"name": "DEBUG",
"outDir": "${workspaceRoot}/build/dist",
"preLaunchTask": "compile",
"program": "${workspaceRoot}/src/App.tsx",
"request": "launch",
"runtimeArgs": [
"--nolazy"
],
"runtimeExecutable": null,
"sourceMaps": true,
"stopOnEntry": false,
"type": "node"
}
]
Run Code Online (Sandbox Code Playgroud)
ts配置:
{
"compilerOptions": {
"outDir": "build/dist",
"module": "commonjs",
"target": "es5",
"lib": ["es6", "dom"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
Run Code Online (Sandbox Code Playgroud)
和工作目录:
我可以使用fetch api新创建的reactjs应用程序.但我正在使用这个模板,它说无法找到fetch api.
什么错了?我遇到了微笑问题,我该如何解决?
还有一对父母div
用id = "cooldiv"
.div
里面有很多元素.现在我需要为所有子div
节点设置一个css属性,除了第一个.
所以,这是我到目前为止完成这项任务所尝试的:
#cooldiv .row:not(first-child) {
top: -50px;
}
Run Code Online (Sandbox Code Playgroud)
但是,当然,它没有成功.这有什么不对?这是源代码的截图:
我的项目结构中有一个 scss 文件夹位于 /src 文件夹之外,这就是为什么对 bu 做出反应
Failed to compile.
./src/index.js
Module not found: You attempted to import ../scss/style.scss which falls outside of the project src/ directory. Relative imports outside of src/ are not supported. You can either move it inside src/, or add a symlink to
it from project's node_modules/.
Run Code Online (Sandbox Code Playgroud)
这是我的 index.js 文件:
import '../scss/style.scss'
ReactDOM.render(
<HashRouter>
<Switch>
<Route path="/" name="Home Page" component={Full}/>
</Switch>
</HashRouter>,
document.getElementById('root'));
registerServiceWorker();
Run Code Online (Sandbox Code Playgroud)
这是 style.scss 文件的内容:
// Override Boostrap variables
@import "bootstrap-variables";
// Import Bootstrap …
Run Code Online (Sandbox Code Playgroud) 我想把汽车图像放在背景图像上,就是这样.
import React, { Component } from 'react';
import {
...
Animated,
ImageBackground
} from 'react-native';
export default class App extends Component {
render() {
return (
<ImageBackground imageStyle={styles.container} source={require('./src/assets/img/road1.jpg')}>
<Animated.Image style={styles.car} source={require('./src/assets/img/car2.png')}>
</Animated.Image>
</ImageBackground>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
position: 'relative',
resizeMode: 'cover'
},
car:{
position:'absolute',
width:100,
height:50
}
});
Run Code Online (Sandbox Code Playgroud)
Type error:undefined is not an object(evaluating 'style.width')
Run Code Online (Sandbox Code Playgroud)
好吧,但为什么它需要'style.width'甚至我使用resizeMode:'cover' 我还在样式对象中设置width和heigth属性仍然是相同的错误..我该如何解决这个问题?
reactjs ×5
react-native ×3
typescript ×2
angular ×1
css ×1
css3 ×1
fullcalendar ×1
html ×1
jquery ×1
react-router ×1