我正在尝试创建一个扩展程序,在打开的 Jupyter Lab 笔记本的工具栏中添加一个自定义按钮,类似于这张照片中的“提交笔记本按钮......”。我如何实现这一目标?我尝试使用以下代码但它不起作用:
import { ToolbarButton } from "@jupyterlab/apputils";
import { DocumentRegistry } from "@jupyterlab/docregistry";
import { INotebookModel, NotebookPanel } from "@jupyterlab/notebook";
import { IDisposable } from "@lumino/disposable";
export class ButtonExtension implements DocumentRegistry.IWidgetExtension<NotebookPanel, INotebookModel> {
createNew(panel: NotebookPanel, context: DocumentRegistry.IContext<INotebookModel>): IDisposable {
// Create the toolbar button
let mybutton = new ToolbarButton({
label: 'My Button',
onClick: () => alert('You did it!')
});
// Add the toolbar button to the notebook toolbar
panel.toolbar.insertItem(10, 'mybutton', mybutton);
// The ToolbarButton class implements `IDisposable`, …Run Code Online (Sandbox Code Playgroud) 我正在设置并尝试从 Laravel 应用程序中检索会话值。Vue Js 前端正在对 Laravel 端点进行 API 调用,该端点设置会话值。包含 Laravel 端点方法的控制器是:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
Use Session;
use App\User;
class UserController extends Controller
{
public function adduser(Request $request) {
$user = User::where( 'sub', $request->sub )->first();
if(!$user) {
$user = new User();
$user->nickname = $request->nickname;
$user->name = $request->name;
$user->sub = $request->sub;
$user->api_token = $request->api_token;
$user->save();
}
$user->api_token = $request->api_token;
$user->save();
return response()
->json([
'done' => $user->api_token
]);
}
//The endpoint for this method is http://localhost:8000/api/set
public function setSession(Request …Run Code Online (Sandbox Code Playgroud) 我正在使用Vue.js为CRUD应用程序创建警报组件。我希望在数据保存后将消息传递给另一个组件。当前,我正在尝试$router.push像这样传递此数据,this.$router.push({path: '/', query: {alert: 'Customer Added'}})然后在另一个组件中访问此数据。但是,这不能按预期工作,而是将数据传递到url中。
这是保存数据的组件Add.vue
<template>
<div class="add container">
<Alert v-if="alert" v-bind:message="alert" />
<h1 class="page-header">Add Customer</h1>
<form v-on:submit="addCustomer">
<div class="well">
<h4>Customer Info</h4>
<div class="form-group">
<label>First Name</label>
<input type="text" class="form-control" placeholder="First Name"
v-model="customer.first_name">
</div>
<div class="form-group">
<label>Last Name</label>
<input type="text" class="form-control" placeholder="Last Name"
v-model="customer.last_name">
</div>
</div>
<div class="well">
<h4>Customer Contact</h4>
<div class="form-group">
<label>Email</label>
<input type="text" class="form-control" placeholder="Email" v-model="customer.email">
</div>
<div class="form-group">
<label>Phone</label>
<input type="text" class="form-control" placeholder="Phone" v-model="customer.phone">
</div>
</div>
<div class="well">
<h4>Customer Location</h4>
<div class="form-group"> …Run Code Online (Sandbox Code Playgroud) 我想在我的Vue.js 2应用程序中搜索或过滤3个字段的名字,姓氏和电子邮件。我知道Vue 2与Vue 1不同,它没有内置的过滤器方法,因此我创建了一个自定义方法,该方法只能通过一个字段进行过滤。如何将此扩展到多个字段?我已经尝试过类似的方法,filterBy(list, value1, value2, value3)但是它不起作用。
这是我的代码
<template>
<div class="customers container">
<input class="form-control" placeholder="Enter Last Name" v-
model="filterInput">
<br />
<table class="table table-striped">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th></th>
</tr>
</thead>
<tbody>
<tr v-for="customer in filterBy(customers, filterInput)">
<td>{{customer.first_name}}</td>
<td>{{customer.last_name}}</td>
<td>{{customer.email}}</td>
<td><router-link class="btn btn-default" v-bind:to="'/customer/'+customer.id">View</router-link></td></tr>
</tbody>
</table>
</div>
</template>
<script>
export default {
name: 'customers',
data () {
return {
customers: [],
filterInput:'',
}
},
methods: {
fetchCustomers(){
this.$http.get('http://slimapp.dev/api/customers')
.then(function(response){
this.customers = …Run Code Online (Sandbox Code Playgroud) 给定以下数组
let array = [[1, 2], [1, 2], [3, 4], [5, 6], [2, 1]]
Run Code Online (Sandbox Code Playgroud)
I want to return the number of distinct arrays in this set. So the example above should return 3. How do I achieve this? I tried the code below, but it does not give the right answer
let distinct = 0
for (let i = 0; i < array.length; i++) {
for (let j = i + 1; j < array.length - i; j++) { …Run Code Online (Sandbox Code Playgroud) javascript ×3
vuejs2 ×3
vue.js ×2
algorithm ×1
arrays ×1
dom ×1
jupyter-lab ×1
laravel ×1
php ×1
session ×1
typescript ×1
vue-router ×1