我正在准备使用Google幻灯片的演示文稿,不过我也可以在Open Office中处理包含代码片段的演示文稿.
有没有简单的方法可以使用Google Docs或Open Office Presenter在代码片段上执行基本语法高亮显示?
编辑:由于我相信我可以找到一种嵌入HTML的方法,任何可以在HTML上执行语法突出显示的工具也是受欢迎的建议.
我正在尝试运行一个编写在教程中的JavaScript代码,如下所示:
main.js
import Vue from 'Vue';
import Alert from './components/Alert.vue';
new Vue({
el: 'body',
components: { Alert }
})
Run Code Online (Sandbox Code Playgroud)
但是,PhpStorm发出以下错误:
当前的JavaScript版本不支持导入声明
如何在PhpStorm中获得更新的(?)JavaScript版本?这真的是问题吗?
我仔细阅读并重新阅读了Vue文档" Resetivity in Depth"以及vm.$ set和Vue.set的API,但我仍然很难确定何时使用哪个.我能够区分这两者是很重要的,因为在我目前的Laravel项目中,我们动态地在对象上设置了很多属性.
文档中的区别似乎是vm.$ set为"For Vue instance"的语言,而Vue.set为"For plain data objects"且Vue.set为global:
但是,有一些方法可以在创建实例后添加属性并使其具有反应性.
对于Vue实例,您可以使用$ set(path,value)实例方法:
vm.$set('b', 2)
// `vm.b` and `data.b` are now reactive
Run Code Online (Sandbox Code Playgroud)
对于纯数据对象,可以使用全局Vue.set(对象,键,值)方法:
Vue.set(data, 'c', 3)
// `vm.c` and `data.c` are now reactive
Run Code Online (Sandbox Code Playgroud)
最后,我想知道上面做的第三个"选项"(用于一次添加多个属性)是否可以用作上述2个选项中的任何一个的等效替代(通过仅添加1个属性而不是多个) ?
有时您可能希望为现有对象分配许多属性,例如使用Object.assign()或_.extend().但是,添加到对象的新属性不会触发更改.在这种情况下,使用原始对象和mixin对象的属性创建一个新对象:
// instead of `Object.assign(this.someObject, { a: 1, b: 2 })`
this.someObject = Object.assign({}, this.someObject, { a: 1, b: 2 })
Run Code Online (Sandbox Code Playgroud) 我试图弄清楚如何在VueJS中制作另一个组件内的一个组件.例如,像这样的东西,遗憾的是不起作用(子组件似乎什么都不做):
http://www.webpackbin.com/NyI0PzaL-
我同样有兴趣使用内联模板,使用.vue文件扩展方法,如上所示.
以下是上述非工作示例中的代码:
main.js
import Vue from 'vue'
import App from './App.vue'
import Child from './Child.vue'
new Vue({
el: 'body',
components: { App, Child }
})
Run Code Online (Sandbox Code Playgroud)
的index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<app></app>
<script src="main.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
App.vue
<template>
<div>
<h1>{{ parent_msg }}</h1>
<child></child>
</div>
</template>
<script>
export default {
data () {
return {
parent_msg: 'Hello From the Parent!'
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
Child.vue
<template>
<h1>{{ child_msg }}</h1>
</template>
<script>
export default {
data () …
Run Code Online (Sandbox Code Playgroud) 在 Vuex 中,我的突变对象如下:
mutations: {
someMethod(){
this.someReusableCode();
},
anotherMethod(){
this.someReusableCode();
},
someReusableCode(){
...
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我收到一个someReusableCode()
未定义的错误。定义我的someReusableCode()
方法的最佳位置在哪里?
在Laravel 4.2中,我有以下过滤器,阻止一个用户查看/编辑/删除不同用户的课程,这是一个基于"课程"模型的对象.这是我使用的代码:
Route::filter('restrictPermission', function($route)
{
$id = $route->parameter('id');
$course = Course::find($id);
$user_id = $course->user_id;
if(Auth::user()->id !== $user_id)
return Redirect::to('/')->with('flash_message', '*** Permission denied ***');
# This compares the currently logged in user's id to the course's
# user ID (in the database) so that the logged in user can
# only view or delete their own courses.
});
Run Code Online (Sandbox Code Playgroud)
这是我试图创建的中间件与上面的过滤器做同样的事情:
<?php
namespace App\Http\Middleware;
use Closure;
class RedirectIfWrongUser
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure …
Run Code Online (Sandbox Code Playgroud) 我试图了解以下函数如何在BcryptHasher.php文件中使用Laravel 4.2:
/**
* Hash the given value.
*
* @param string $value
* @param array $options
* @return string
*
* @throws \RuntimeException
*/
public function make($value, array $options = [])
{
$cost = isset($options['rounds']) ? $options['rounds'] : $this->rounds;
$hash = password_hash($value, PASSWORD_BCRYPT, ['cost' => $cost]);
if ($hash === false) {
throw new RuntimeException('Bcrypt hashing not supported.');
}
return $hash;
}
Run Code Online (Sandbox Code Playgroud)
我想我理解除了这一行之外的一切:
$cost = isset($options['rounds']) ? $options['rounds'] : $this->rounds;
Run Code Online (Sandbox Code Playgroud)
我知道$ this-> rounds的默认值设置为10,然后是密码将被散列的"成本".但是,我对$ options数组正在做什么以及如何影响成本感到困惑?
我有一个相当新的Macbook Pro,我只是尝试按照其网站上的说明安装自制软件:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
但是,当我运行此命令时,将得到以下输出:
The user \u cannot be found
There was an unknown error.
This script requires the user \u to be an Administrator.
我的Macbook只有1个用户,也就是我,管理员。这就是我在计算机上登录的身份。
我尝试过的另一件事是使用运行命令sudo
,在这种情况下,我收到以下消息:
Don't run this as root!
我尝试过的另一件事是下载,Command Line Tools (CLT) for Xcode: xcode-select --install
因为我在Homebrew网站和在线其他地方看到了此建议。
在创建具有除我的root帐户以外的“ Admin”特权的新用户之后,上面的homebrew install命令开始运行,但随后退出并显示以下错误:
/usr/local/homebrew/.git: Permission denied
Failed during: git init -q
在这一点上,我被卡住了,不确定该怎么做。
我是使用硒的新手.我已经下载了Selenium Standalone Server并通过输入成功运行了它
java -jar selenium-server-standalone-2.14.0.jar
Run Code Online (Sandbox Code Playgroud)
进入命令行.
跑完之后
phpunit.bat
Run Code Online (Sandbox Code Playgroud)
从命令行开始,我的所有测试都将按预期传递,除非我手动最大化在测试过程中自动打开的Firefox浏览器窗口.
当测试运行时,当Firefox浏览器窗口打开时,如果我在登录测试运行时没有最大化该窗口,那么该测试将失败并以某种方式重定向到我网站上的意外页面.如果我在测试完成之前最大化窗口,则按预期单击"登录"按钮,加载正确的页面,测试通过.
因此,我想知道是否有办法在某处更改设置,以便Firefox浏览器在测试运行时只打开最大化?
我已经用Google搜索并发现了一些可能有用的代码片段,但我不确定这段代码的PHP版本在哪里,或者在哪里为我正在使用的Selenium版本放置一些类似的代码(Selenium Standalone Server) ):
# repositioning and resizing browser window:
driver.manage.window.move_to(300, 400)
driver.manage.window.resize_to(500, 800)
driver.manage.window.maximize
Run Code Online (Sandbox Code Playgroud)
或者这是C#,但我需要PHP,不知道在哪里找到合适的代码或在哪里放置它:
driver.Manage().Window.Maximize();
Run Code Online (Sandbox Code Playgroud)
以下是我的tests/SeleniumTest.php文件中登录Selenium测试的代码(使用Laracasts/Integrated):
<?php
use Laracasts\Integrated\Extensions\Selenium;
use Laracasts\Integrated\Services\Laravel\Application as Laravel;
class SeleniumTest extends Selenium
{
use Laravel;
/**
* Tests to see if the login page loads
*/
public function testToSeeIfLoginLoads()
{
$this->visit('/login')
->see('Login')->see('Email Address')->see('Password')
->type('myemail@email.com', 'email')->type('mypassword', 'password')
->waitForElement('log_in')
->click('log_in')
->waitForElement('table_summary')
->see('Complete Course Summary');
}
Run Code Online (Sandbox Code Playgroud) 我正在查看以下vue-resource文档,该文档描述了如何设置配置:https: //github.com/vuejs/vue-resource/blob/master/docs/config.md
它说要使用通用授权值设置标头:
Vue.http.headers.common['Authorization'] = 'Basic YXBpOnBhc3N3b3Jk';
Run Code Online (Sandbox Code Playgroud)
我猜这个"基本的YXBpOnBhc3N3b3Jk"值只是一个例子,但是这个值是什么,应该用什么而不是它呢?
在同一页面上,我还看到了"root"的设置:
Vue.http.options.root = '/root';
Run Code Online (Sandbox Code Playgroud)
我理解这是指Web应用程序的Web URL.但是,为什么vue-resource需要我告诉它这个值呢?它用于什么?
javascript ×5
laravel ×4
php ×4
vue.js ×4
laravel-5.1 ×3
laravel-4 ×2
laravel-5 ×2
phpstorm ×2
curl ×1
ecmascript-6 ×1
editor ×1
firefox ×1
google-docs ×1
homebrew ×1
presentation ×1
ruby ×1
selenium ×1
terminal ×1
unit-testing ×1
vue-resource ×1
vuejs2 ×1
vuex ×1
webstorm ×1
xcode ×1