我正在使用Vue2.x,我想通过使用自定义指令添加事件监听器。但是在vue1.x中,我可以使用下面的代码片段:
Vue.directive('demo',{
bind () {
let self = this
this.event = function (event) {
self.vm.$emit(self.expression, event)
}
this.el.addEventListener('click', this.stopProp)
document.body.addEventListener('click', this.event)
}
})
Run Code Online (Sandbox Code Playgroud)
但是在vue2.x中,我发现'this'始终是不确定的。而且我不知道如何获取vm(Vue Instance)对象。我已经尝试了文档中所有传递的参数列表。
有谁知道如何访问vm对象?
好吧,我可能有个小问题,但我不知道。
如果我仅使用axios通过一个http请求,则一切正常。
但是当我使用多个请求时,会在控制台日志中得到结果,但无法发送以查看文件(laravel刀片视图文件)。
让我告诉你我的代码:
brand.blade.php
// main element for Vue js el: '#container'
<div id="container" class="row all_brands">
<brands></brands>
</div>
// template for brand component
<template id="brand-template">
<ul>
// if I only pass one http request through axios then my data shows here but for multiple request not showing anything.
<li v-for="brand in list" v-text="brand.brand_id"></li>
</ul>
@{{count}}
</template>
Run Code Online (Sandbox Code Playgroud)
brand.js
Vue.component('brands',{
template: '#brand-template',
data: function(){
return{
list: [],
count: ''
}
},
created: function(){
//axios.get('api/brands').then(response => this.list = response.data) ; // here …Run Code Online (Sandbox Code Playgroud) 我正在通过希望显示在列表中的 API 访问数据。我现在正在测试 VueJS,但无法正确显示它。
数据是:
{
"data": [
{
"userReference": "R100",
"responderStatus": 0,
"location": {
"latitude": 100,
"longitude": 100,
"distance": null
},
"featureTypeId": 1
}
],
"pagination": {
"total": 1,
"perPage": 10,
"lastPage": 1,
"nextPageUrl": null,
"prevPageUrl": null,
"from": 1,
"to": 1,
"totalPages": 1,
"currentPage": 1,
"hasMorePages": false
}
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-12">
<div class="text-center m-t-lg">
<h1>MEDIFAKTOR server</h1>
</div>
<div id="app">
<ul class="list-group">
<li v-for="responder in responders">@{{ responder[0] }}</li>
</ul>
</div>
</div>
</div> …Run Code Online (Sandbox Code Playgroud) 我使用的传送带的引导V4在VUE Web应用程序.我在示例示例中使用它,但它不在我的本地工作,也没有给出任何错误.
<div class="col-xs-5 card prod-img">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img src="../../assets/animals/rat.png" alt="First slide">
</div>
<div class="carousel-item">
<img src="../../assets/animals/cat.png" alt="Second slide">
</div>
<div class="carousel-item">
<img src="../../assets/animals/dog.png" alt="Third slide">
</div>
</div>
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="icon-prev" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="icon-next" aria-hidden="true"></span>
<span class="sr-only">Next</span> …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个 Leaflet 地图作为 Vue 组件,但我有一些困难的开始。我通过 npm 安装了 Leaflet
我哪里错了?console.log(Leaflet) 正在返回一个 Leaflet 对象,但我无法让地图展开和渲染。
一些方向将不胜感激
<template>
<div id="map"></div>
</template>
<script>
// import leaflet here?
import Leaflet from 'leaflet';
export default {
components: {
Leaflet
},
created() {
console.log(this);
console.log(Leaflet);
},
ready() {
this.map = L.map('map').setView([51.959, -8.623], 14);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(this.map);
}
}
</script>
<style>
#map {
height: 100%;
width: 100%;
margin-top: -24px;
}
/* default legend, layer styling from leaflet template */
.info {
padding: 6px 8px; …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
require "ostruct"
arguments = [OpenStruct.new({:name=>"ABCD", :city => "Delhi"}),
OpenStruct.new({:name=>"Awesome", :city => "Bhiwandi"}),
OpenStruct.new({:name=>"good", :city => "Chandigarh"})]
arguments.map(&:name)
#results ["ABCD", "Awesome", "good"]
Run Code Online (Sandbox Code Playgroud)
但我想要的是:
[["ABCD", "Delhi"], ["Awesome", "Bhiwandi"], ["good", "Chandigarh"]]
Run Code Online (Sandbox Code Playgroud)
我可以通过以下方式获得:
arguments.map(&:name).zip(arguments.map(&:city))
Run Code Online (Sandbox Code Playgroud)
但是,是否有一些更优雅的方式来做,像arguments.map(&[:name, :city]).?
我有个问题.如何转换IDictionary<string, object>为课程?以及创建用户帐户.
WebSecurity.CreateUserAndAccount(UserName, Password, new { eny = 0 , eny2 = "sas"});
Run Code Online (Sandbox Code Playgroud)
我有
void Create(String name, IDictionary<string, object> values)) {...}
Run Code Online (Sandbox Code Playgroud)
和班级
class test {
String name,
int eny,
int eny2
}
Run Code Online (Sandbox Code Playgroud)
我想用字典中的数据进行对象测试.