小编Sau*_*abh的帖子

映射在活动记录中的范围

我有一个活跃的记录,我有一个用例:我想用mapActiveRecord scopes.以下是我的代码:

class SupportedGeoIdAndLocation < ActiveRecord::Base

   scope :supported_geo_ids,            lambda { all.map(&:geo_id).uniq }
   # also tried: scope :supported_geo_ids,            lambda { select('distinct geo_id').map(&:geo_id).uniq }
   scope :locations_for_geo_id, lambda { |geo_id| where(:geo_id => geo_id).map(&:location) }
end
Run Code Online (Sandbox Code Playgroud)

但当我这样做时,SupportedGeoIdAndLocation.supported_geo_ids我得到空阵列,同时SupportedGeoIdAndLocation.all.map(&:geo_id).uniq给我想要的结果.

我正在寻找一种方法,这样就可以一次性使用lambda,而不是通过链接不同的方法,完全避免类函数.

看起来我以错误的方式使用示波器,请建议我可以采用哪种方法.

版本:: padrino0.10.5,ruby:ruby-1.9.3-p429,ActiveRecord:3.1.6

ruby activerecord padrino

2
推荐指数
1
解决办法
2256
查看次数

“未知的自定义元素:&lt;router-link&gt;”升级到Vue 2

从vue 1和vue-router 0.7升级了应用程序,并在控制台中收到此错误

[Vue警告]:未知的自定义元素:-您是否正确注册了组件?对于递归组件,请确保提供“名称”选项。(位于组件中……[调用组件的路径]

import Vue from 'vue';
import VueResource from 'vue-resource';
import VueRouter from 'vue-router';
import gsap from 'gsap';

Vue.use( VueResource );
Vue.use( VueRouter );

window.flipster = require( 'jquery.flipster' );
window.spritespin = require('SpriteSpin');

// Main Layout Components
import Menu from './components/Menu.vue';
import Section from './components/Section.vue';

// Controller Layout Components
import ControllerMenu from './components/Controller/Menu.vue';
import ControllerSection from './components/Controller/Section.vue';

// Generic Components
import Tabs from './components/Tabs.vue';
Vue.component( 'tabs', Tabs );

import Tab from './components/Tab.vue';
Vue.component( 'tab', Tab );

import Chart from …
Run Code Online (Sandbox Code Playgroud)

vue.js vue-router

2
推荐指数
1
解决办法
6499
查看次数

bootstrap-4 中的标签是否被删除

之前有label在 bootstrap 中命名的组件,请参阅此处的文档和下面的示例:

<h3>Example heading <span class="label label-default">New</span></h3>
Run Code Online (Sandbox Code Playgroud)

我无法在bootstrap-4中找到这些,这些是否已被删除,有什么方法可以通过 bootstrap-4 获得它。

twitter-bootstrap bootstrap-4

2
推荐指数
1
解决办法
5930
查看次数

VueJS 转换“输入”不起作用

我正在尝试做一个相当简单的可折叠菜单转换。我的元素看起来像:

<transition name="settings">
    <div v-show="!settingsCollapsed">
    </div>
</transition>
Run Code Online (Sandbox Code Playgroud)

我的 css 看起来像

.settings-enter {
  max-height: 0px;
}
.settings-enter-active {
  max-height: 200px;
  transition: all 1s;
}
.settings-leave {
  max-height: 200px;
}
.settings-leave-active {
  max-height: 0;
  transition: all 1s;
}
Run Code Online (Sandbox Code Playgroud)

我的菜单正确向上滑动,但是当它向下滑动时它没有动画。在我看来,它.settings-enter从未被应用过,它只是从隐藏到上课.settings-enter-active

任何建议如何解决这个问题,或者为可折叠菜单设置动画的替代方法?

css transitions vue.js

2
推荐指数
2
解决办法
5079
查看次数

无法向Vue存储中的变异发送第二个参数

我有一个很好的变异JS文件,像这样.

export default {
  UPDATE_DATA: (state, data, meta) => {
    state.dataTable = data;

    if (meta === undefined)
      return;

    state.activeDataRow = meta;
  }, ...
}
Run Code Online (Sandbox Code Playgroud)

它通过以下方式被不同的行为召唤.

context.commit("UPDATE_DATA", Map.table(payload.type, data));
context.commit("UPDATE_DATA", Map.table(payload.type, data), meta);
Run Code Online (Sandbox Code Playgroud)

我检查了动作中发送的元数据,它绝对不是未定义的.但是,当我检查突变中的meta时,它就是!为什么?我该如何解决这个问题?

javascript vue.js vuex

2
推荐指数
1
解决办法
2899
查看次数

Vuejs 2服务器端渲染 - 无法正常工作

我一直在努力使我的vuejs应用程序与SSR功能良好,但我的所有尝试都失败了.我真的需要帮助.

请注意,我使用普通的js文件,而不是使用es6的.vue文件,并且需要使用webpack require函数的html模板.

该应用程序在开发模式下工作正常,但是,当我使用'vue-server-renderer'开始执行它并转到任何路由时,将抛出此错误:

错误:在组件中未定义渲染函数或模板:在presentationComponent(/ Users/salaahassi /)上的normalizeRender(/Users/salaahassi/dev/vue/magicum/node_modules/vue-server-renderer/build.js:6015:13)中匿名dev/vue/magicum/node_modules/vue-server-renderer/build.js:6081:3)在renderNode(/Users/salaahassi/dev/vue/magicum/node_modules/vue-server-renderer/build.js:6065: 7)在渲染(/Users/salaahassi/dev/vue/magicum/node_modules/vue-server-renderer/build.js:6257:5)RenderStream.render(/ Users/salaahassi/dev/vue/magicum/node_modules /) vue-server-renderer/build.js:6312:9)RenderStream.tryRender(/Users/salaahassi/dev/vue/magicum/node_modules/vue-server-renderer/build.js:96:12)在RenderStream._read (/ Users/salaahassi/dev/vue/magicum/node_modules/vue-server-renderer/build.js:125:12)在RenderStream.Readable.read(_stream_readable.js:348:10)的resume_(_ stream_readable.js: 737:12)在_combinedTickCallback(internal/process/next_tick.js:74:11)

此外,当我在我的浏览器上禁用javascript时,即使主页也会消失(当然这是因为它不能通过SSR工作).

这是我的webpack:

var path = require('path')
var webpack = require('webpack')
var HTMLPlugin = require('html-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var extractCSS = new ExtractTextPlugin('styles.css');

var options = {
  // entry: './entry.client.js',
  entry: {
    app: './entry.client.js',
    vendor: [
      'vue',
      'vue-router',
      'vuex',
      'vuex-router-sync',
      'moment',
      'axios'
    ]
  },
  output: {
    path: path.resolve(__dirname, './dist'),
    publicPath: '/',
    filename: '[name].[hash].js',
  },
  module: {
    noParse: /es6-promise\.js$/, // avoid webpack …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js server-side-rendering vue-router vuejs2

2
推荐指数
1
解决办法
2898
查看次数

Couchbase元数据开销警告

我有一个Couchbase(v 2.0.1)群集,其中包含以下规范:

  • 5个节点
  • 1桶
  • 每节点16 GB Ram(总共80GB)
  • 每节点200GB磁盘(总共1Tb)

目前我在这个桶中有201.000.000个文件,只有200GB的磁盘在使用中.

我每分钟都会收到以下警告:

Metadata overhead warning. Over 51% of RAM allocated to bucket "my-bucket" on node "my-node" is taken up by keys and metadata. 
Run Code Online (Sandbox Code Playgroud)

Couchbase文档说明了以下内容:

表示存储桶现在使用超过50%的已分配RAM来存储元数据和密钥,从而减少了可用于数据值的RAM量.

我知道这可能是一个有用的指标,我可能需要将节点添加到我的集群,但我认为这应该是不必要的,因为桶的可用资源量.

一般桶分析: 一般桶分析

我怎么知道是什么产生了如此多的元数据?

有没有办法配置公差百分比?

nosql couchbase

1
推荐指数
1
解决办法
3210
查看次数

我的Vuejs javascript文件中的令牌无效或意外

在我的vue组件js代码中,我收到此错误:

未捕获的SyntaxError:无效或意外的令牌

这是我的代码:

Vue.component('pickpoint-info', {

    template : '<table>\ // in this line I get the error
                    <tbody>\
                        <tr v-for="item in items" v-on:click="selectPickPoint(this)">\
                            <td width="50" align="center"><input name="pickpointid" type="radio" value="{{ item.customer_id }}"></td>\
                            <td width="300">\
                                <b>{{ item.name }}</b> <i style="font-size:9px;">#{{ item.customer_id }}</i>\
                                <br>\
                                {{ item.address }}\ 
                                <br>\ 
                                {{ item.postal_code }}\
                                <a href="{{ item.map_link }}" target="_blank" style="font-size:10px;">(ver en el mapa</a>)\
                            </td>\
                        </tr>\
                    </tbody>\
                </table>\
    ',
Run Code Online (Sandbox Code Playgroud)

这段代码有什么问题?

javascript vue.js vue-component

1
推荐指数
1
解决办法
7364
查看次数

v-html无法在Vue 2中呈现vue组件

我正在尝试使用道具渲染组件。但是仅当内容道具不是组件时才起作用。

这是一个示例:https : //jsfiddle.net/eugenio4/onf54vt5/

// register modal component
Vue.component('component', {
  template: '<span class="component-tag">This is component</span>',
})

// start app
new Vue({
  el: '#app',
  data: function (){
    return {
        test1 : '<label>this is label</label>',
        test2 : '<component></component>' //this doest work
    }
  }
})

<!-- app -->
<div id="app">  
  <span v-html="test1"></span>
  <span v-html="test2"></span>
</div>
Run Code Online (Sandbox Code Playgroud)

这可能吗?

vue.js

1
推荐指数
1
解决办法
4620
查看次数

Vue Js-axios的问题与laravel执行多个并发请求

好吧,我可能有个小问题,但我不知道。

如果我仅使用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)

vue.js laravel-5 laravel-blade vue-component

1
推荐指数
1
解决办法
1874
查看次数