我尝试将Angular 4的POST请求发送到我的Laravel后端.
我的LoginService有这个方法:
login(email: string, password: string) {
return this.http.post(`http://10.0.1.19/login`, { email, password })
}
Run Code Online (Sandbox Code Playgroud)
我在LoginComponent中订阅了这个方法:
.subscribe(
(response: any) => {
console.log(response)
location.reload()
},
(error: any) => {
console.log(error)
})
Run Code Online (Sandbox Code Playgroud)
这是我的Laravel后端方法:
...
if($this->auth->attempt(['email' => $email, 'password' => $password], true)) {
return response('Success', 200);
}
return response('Unauthorized', 401);
Run Code Online (Sandbox Code Playgroud)
我的Chrome开发工具说我的请求是成功的200状态代码.但我的Angular代码触发了error阻止并给了我这条消息:
解析http://10.0.1.19/api/login期间的Http失败
如果我从后端返回一个空数组,它可以工作......所以Angular试图将我的响应解析为JSON?我怎么能禁用它?
我还是初学者,我尝试将一个类导出并导入到主文件中,另一个类导入其他类文件并使用它们.
然后用6to5(现在的Babel)吞下ES5代码.
// file a.js
import B from 'b.js';
class A {
constructor() {
B.methodB();
}
}
export default A;
// file b.js
class B {
methodB() {
console.log('hi from b');
}
}
export default B;
// file main.js
import A from 'a.js';
new A();
Run Code Online (Sandbox Code Playgroud)
我的gulpfile:
var gulp = require('gulp');
var to5 = require('gulp-6to5');
gulp.task('default', function () {
return gulp.src('main.js')
.pipe(to5())
.pipe(gulp.dest('dist'));
});
Run Code Online (Sandbox Code Playgroud)
这是我的dist/main.js档案:
"use strict";
var _interopRequire = function (obj) {
return obj && (obj["default"] || obj); …Run Code Online (Sandbox Code Playgroud) 我在IIS 8(Win 2012)服务器上运行了多个PHP(Laravel)应用程序.这是web.config我所有应用的文件:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)/$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
但是在一个应用程序中,IIS不时会出现问题:我的应用程序不起作用,因为URL错误.如果我重新启动Web服务器或更改web.config文件(添加空格或其他内容......),它将再次起作用.
我不知道......我的其他应用程序没有问题,而且web.config代码相同.
所有用户(IIS_IUSR,管理员等)都具有完全的写入和读取访问权限.
我的应用程序在文件夹中构建,请参见此处:
我称之为10.0.0.7/doku或10.0.0.7/lagerverwaltung.
我为Firefox和Chrome构建了一个Web扩展插件.在Chrome中,地址栏为空,这也是我想要Firefox的原因.
如果我点击"新标签页",地址栏上会设置以下网址:moz-extension://5a4137a2-ede8-4f1d-838c-20069831ab38/index.html.我可以将其更改为其他内容吗?一个空的地址栏会很棒.
这是我的manifest.json
...
"chrome_url_overrides" : {
"newtab": "index.html"
},
"permissions": [
"activeTab"
],
...
Run Code Online (Sandbox Code Playgroud) 有没有办法使用soundcloud api 访问新图表https://soundcloud.com/charts/top(前50名)?或者还有其他方式吗?
也许用php或其他东西爬行?
//编辑:我想我已经解决了问题.我需要从vue独立构建...
我已将我的vue.js 1.0应用程序迁移到vue.js 2.0(使用迁移帮助程序).但是这个错误在控制台中显示了我Failed to mount component: template or render function not defined. (found in root instance).
这是我简化的main.js:
import Vue from 'vue';
import Router from 'vue-router';
import SiteHeader from './components/Header.vue';
import Content from './components/Content/Content.vue';
import SiteFooter from './components/Footer.vue';
Vue.use(Router);
const router = new Router({
mode: 'history',
root: '/',
routes: [
{ path: '/', component: Content }
]
});
new Vue({
router,
components: {
SiteHeader, SiteFooter
}
}).$mount('body');
Run Code Online (Sandbox Code Playgroud)
这Content.vue是一个vue包含模板和脚本的普通文件(这里没什么特别的).
我的'route-view`是在laravel.blade文件中定义的
@if(Request::is('login'))
<login></login>
@else
<site-header></site-header>
<router-view></router-view> …Run Code Online (Sandbox Code Playgroud) 我有一个小程序,当您单击“条目”时,将打开编辑模式,而该条目是为其他人锁定的。每隔10秒就会发送一个ajax请求来更新表中的时间戳。
$(".entry-edit").click(function() {
// code
loopLockingVar = setInterval(function() { loopLockingFunction(id) }, 10000);
// code
});
Run Code Online (Sandbox Code Playgroud)
然后,我有一个取消按钮,将表中的时间戳更新为0并清除间隔。
$(".entry-cancel").click(function() {
// code
clearInterval(loopLockingVar);
// code
});
Run Code Online (Sandbox Code Playgroud)
当仅编辑一个条目时,所有操作均有效,但是如果同时处理两个或多个条目,然后单击“取消”,则第一个条目的间隔会更远...
我试过了
var loopLockingVar;
$(".entry-edit").click(function() {
// code
if( ! loopLockingVar) {
loopLockingVar = setInterval(function() { loopLockingFunction(id) }, 10000);
}
// code
});
Run Code Online (Sandbox Code Playgroud)
但是,如果您取消并再次单击“编辑”,此方法将无法正常工作。
我有以下反应本机应用程序结构(simpilifed)
- /MyApp
- /ios
- data.json
- index.ios.js
Run Code Online (Sandbox Code Playgroud)
因此,我需要访问并写入data.json文件。要访问它们,我可以 import Data from './data.json'。
但是我如何写入该文件?我看到了react-native-fs(https://github.com/johanneslumpe/react-native-fs),但是我无法访问MyApp目录中的文件。
我该如何存储类似my的文件data.json,以便可以在iPhone上编写和访问它们?
我的data.json文件包含更大的词汇表,例如
{
"words": [
{"word": "xxx", "done": false} // and more...
]
}
Run Code Online (Sandbox Code Playgroud) javascript ×2
angular ×1
babeljs ×1
ecmascript-6 ×1
firefox-addon-webextensions ×1
iis ×1
json ×1
php ×1
react-native ×1
setinterval ×1
soundcloud ×1
typescript ×1
vue.js ×1