我正在尝试按照这些说明使用打字稿模板创建一个新项目。
npx create-react-app app-ui --template typescript
Run Code Online (Sandbox Code Playgroud)
尽管它安装了所有节点模块,但它不会创建启动项目,也不会使用提供的模板。我收到这条消息:
A template was not provided. This is likely because you're using an outdated version of create-react-app.
Please note that global installs of create-react-app are no longer supported.
Run Code Online (Sandbox Code Playgroud)
我正在尝试按照说明删除 cli 的全局安装,但这也不起作用:
npm uninstall -g create-react-app
up to date in 0.037s
Run Code Online (Sandbox Code Playgroud)
无论我做什么,我都无法卸载 cli。到底是怎么回事?
编辑:
我能够让它在 PC 上部分工作。
npm remove create-react-app
Run Code Online (Sandbox Code Playgroud)
然后
npx create-react-app my-app [--template typescript]
Run Code Online (Sandbox Code Playgroud)
我尝试使用括号,虽然模板项目在那里,但它不在打字稿中。现在 cli 有问题。
编辑:
这篇文章解决了无法卸载cli的问题。希望这对某人有所帮助,并请为 OP 投票。
我正在尝试用ngRoute组合我的第一个角度组件,到目前为止,我无法获得要解决的数据.配置:
.when('/myfirstcomponent', {
template: '<myfirstcomponent claimKeys="$resolve.claimKeys"></myfirstcomponent>',
resolve: {
claimKeys: ['$http', function($http) {
$http.get('server/claimkeys.json').then((response) => {
var claimKeys = response.data.DATASET.TABLE;
return claimKeys;
});
}]
}
})
Run Code Online (Sandbox Code Playgroud)
零件:
.component('myfirstcomponent', {
bindings: {
'claimKeys': '@'
},
templateUrl: 'components/component.html',
controller: [function() {
this.$onInit = function() {
var vm = this;
console.log(vm.claimKeys);
};
}]
Run Code Online (Sandbox Code Playgroud)
组件的html只有ap元素,其中包含一些随机文本.
我可以看到调试时我正在检索数据,但我无法在组件控制器上访问它...
编辑:感谢下面接受的答案,我解决了我的问题.它与异步调用的问题没有任何关系,但与我如何定义我的路由和组件有关.请参阅以下代码进行修复.再次感谢.
我正在尝试调试一个小项目,但我无法让Debugger for Chrome扩展完全正常工作.当我放置一个断点时,它会移动到我想要调试的函数之外.
我正在使用webpack + babel.我的项目是在.Net平台(特别是DNN)上托管的.
的package.json:
{
"name": "disable-registration",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack",
"test": "echo \"Error: no test specified\" && exit 1",
"watch": "npm-watch"
},
"babel": {
"presets": [
"env"
]
},
"watch": {
"build": "src/*.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"jquery": "^3.3.1"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.3",
"babel-preset-env": "^1.6.1",
"npm-watch": "^0.3.0",
"webpack": "^4.0.1",
"webpack-cli": "^2.0.9"
}
}
Run Code Online (Sandbox Code Playgroud)
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome", …Run Code Online (Sandbox Code Playgroud)