小编Epi*_*lle的帖子

将道具动态传递给VueJS中的动态组件

我有一个动态的观点:

<div id="myview">
  <div :is="currentComponent"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

与关联的Vue实例:

new Vue ({
  data: function () {
    return {
      currentComponent: 'myComponent',
    }
  },
}).$mount('#myview');
Run Code Online (Sandbox Code Playgroud)

这允许我动态地更改我的组件.

就我而言,我有三个不同的部分组成:myComponent,myComponent1,和myComponent2.我在他们之间切换如下:

Vue.component('myComponent', {
  template: "<button @click=\"$parent.currentComponent = 'myComponent1'\"></button>"
}
Run Code Online (Sandbox Code Playgroud)

现在,我想把道具传递给myComponent1.

当我将组件类型更改为时,如何传递这些道具myComponent1

javascript vue.js vue-component vuejs2

72
推荐指数
3
解决办法
3万
查看次数

范围引用而不是值

我看到该范围返回键和值的"副本".该范围是否有办法返回该项目的地址?例

package main

import "fmt"

type MyType struct {
    field string
}

func main() {
    var array [10]MyType

    for _, e := range array {
        e.field = "foo"
    }

    for _, e := range array {
        fmt.Println(e.field)
        fmt.Println("--")
    }
}
Run Code Online (Sandbox Code Playgroud)

http://play.golang.org/p/AFOGG9NGpx

这里"字段"没有被修改,因为范围发送字段的副本,我是否必须使用索引或是否有任何其他方法来修改值?

谢谢阅读.

pointers reference go

66
推荐指数
3
解决办法
3万
查看次数

使用Content-Type multipart/form-data的golang POST数据

我正在尝试使用go将图像从我的计算机上传到网站.通常,我使用bash脚本将文件和密钥发送到服务器:

curl -F "image"=@"IMAGEFILE" -F "key"="KEY" URL
Run Code Online (Sandbox Code Playgroud)

它工作正常,但我正在尝试将此请求转换为我的golang程序.

http://matt.aimonetti.net/posts/2013/07/01/golang-multipart-file-upload-example/

我尝试了这个链接和许多其他链接,但是,对于我尝试的每个代码,来自服务器的响应是"没有图像发送",我不知道为什么.如果有人知道上面的例子发生了什么.

谢谢

curl file-upload multipart go

62
推荐指数
4
解决办法
6万
查看次数

将中心项目视为v-flex

我试图把一个中心<v-btn>变成一个<v-flex>.由于<v-flex>是一个flexbox div,我使用justify-center它转换成

justify-content: center
Run Code Online (Sandbox Code Playgroud)

由于我的方向是水平的,我的按钮应该居中对齐,但事实并非如此.这是重现我的问题的codepen.

https://codepen.io/anon/pen/ZXLzex

我想注册按钮在div(v-flex)内居中.

这是完整的代码:

 <v-card>
    <v-card-text >
          <v-text-field label="Email"></v-text-field>
          <v-text-field label="Password"></v-text-field>
    </v-card-text>

    <v-card-actions>
        <v-layout row>
          <v-flex justify-center>
            <v-btn primary>
              Signup
            </v-btn>
          </v-flex>
        </v-layout>
    </v-card-actions>
  </v-card>
Run Code Online (Sandbox Code Playgroud)

flexbox vuejs2 vuetify.js

26
推荐指数
2
解决办法
6万
查看次数

快速将Bitmap转换为BitmapSource wpf

我需要Image在30Hz处在组件上绘制图像.我用这个代码:

public MainWindow()
    {
        InitializeComponent();

        Messenger.Default.Register<Bitmap>(this, (bmp) =>
        {
            ImageTarget.Dispatcher.BeginInvoke((Action)(() =>
            {
                var hBitmap = bmp.GetHbitmap();
                var drawable = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                  hBitmap,
                  IntPtr.Zero,
                  Int32Rect.Empty,
                  BitmapSizeOptions.FromEmptyOptions());
                DeleteObject(hBitmap);
                ImageTarget.Source = drawable;
            }));
        });
    }
Run Code Online (Sandbox Code Playgroud)

问题是,使用此代码,我的CPU使用率约为80%,如果没有转换,则大约为6%.

那么为什么转换位图这么久呢?
是否有更快的方法(使用不安全的代码)?

c# wpf copy bitmap bitmapsource

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

WPF图像停止重新绘制

使用WPF和MVVM我试图将相机图像显示为Image.每个帧相机都有一个回调叫做:

视图模型

public void OnNewFrame(object sender, EventArgs e)
{
    Camera camera = sender as MyCamera;
    camera.ToBitmap(out _bmpImage);
    RaisePropertyChanged("BMPImage");
}
Run Code Online (Sandbox Code Playgroud)

每一帧,我更新变量_bmpImage:

视图模型

private Bitmap _bmpImage;
public Bitmap BMPImage
{
    get
    { return _bmpImage; }
    private set
    { _bmpImage = value; RaisePropertyChanged("BMPImage"); }
}
Run Code Online (Sandbox Code Playgroud)

为了转换BitmapBitmapImage我使用转换器:

变流器

public class ImageToSource : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter,
                System.Globalization.CultureInfo culture)
        {
            Image image = value as Image;
            if (image != null)
            {
                MemoryStream ms …
Run Code Online (Sandbox Code Playgroud)

c# wpf graphics mvvm

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

javascript中的链承诺

为了在我的数据库中创建对象,我已经创建了许多类似的承诺.

var createUserPromise = new Promise(
  function(resolve, reject) {
    User.create({
      email: 'toto@toto.com'
    }, function() {
      console.log("User populated"); // callback called when user is created
      resolve();
    });
  }
); 
Run Code Online (Sandbox Code Playgroud)

最后,我想按照我想要的顺序打电话给我所有的承诺.(因为某些对象依赖于其他对象,所以我需要保留该顺序)

createUserPromise
  .then(createCommentPromise
    .then(createGamePromise
      .then(createRoomPromise)));
Run Code Online (Sandbox Code Playgroud)

所以我希望看到:

User populated
Comment populated
Game populated
Room populated
Run Code Online (Sandbox Code Playgroud)

不幸的是,这些消息被洗牌,我不明白是什么.

谢谢

javascript mongoose node.js promise

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

如何在视图模型中获取鼠标位置

从MVVM设计模式来看,viewmodel不应该知道视图.但就我而言,我需要视图和模型,我的意思是:

在我的窗口中,我有一个Image组件.当鼠标移过Image组件并将其保存到我的模型中时,我想获得鼠标位置.

背后的代码是:

void Foo_MouseMove(objet sender, MouseEventArgs e)
{
  model.x = e.getPosition(this.imageBox).X; 
  model.y = e.getPosition(this.imageBox).Y;
}
Run Code Online (Sandbox Code Playgroud)

问题是:我需要this.imageBox和MouseEventArgs,所以两个View元素.

我的问题是:如何使用MVVM方法处理这种情况?

我使用MVVM轻量级框架

c# wpf mvvm

6
推荐指数
3
解决办法
5866
查看次数

SQLITE日期没有选中类型

我刚刚测试了sqlite并创建了一个表.

$sqlite3 plop.db

sqlite> CREATE TABLE t (d DATE);

sqlite> INSERT INTO t (d) VALUES ('Hello');

sqlite> PRAGMA table_info(t);
0|a|DATE|0||0

sqlite> SELECT * FROM t;
Hello
Run Code Online (Sandbox Code Playgroud)

那么,当我尝试将CHAR(5)插入DATE时,为什么没有错误?

sql sqlite date

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

画布%%in frame%没有框架%size

我用球拍创造了一个小蛇游戏,我试图展示边界.

我定义了一些constantes:

(define WIDTH 500)

(define HEIGHT 500)

(define BLK_SIZE 10)
Run Code Online (Sandbox Code Playgroud)

所以,所有块都是50px的正方形.

我创建了一个帧%

(define frame 
  (new (class frame%
         (define/augment (on-close)
           (send timer stop)
           (printf "ending...\n"))
         (super-new))
       [label "Snake"]
       [width WIDTH]
       [height HEIGHT]))
Run Code Online (Sandbox Code Playgroud)

和帆布%

(define game-canvas%
  (class canvas%
    (define/override (on-char e)
      (case (send e get-key-code)
        [(left) (unless (eq? last-dir 'right)
                  (set! dir 'left))]
        [(right) (unless (eq? last-dir 'left)
                   (set! dir 'right))]
        [(up) (unless (eq? last-dir 'down)
                (set! dir 'up))]
        [(down) (unless (eq? last-dir 'up)
                  (set! dir 'down))]
        [else (void)]))

    (super-new)))
;... …
Run Code Online (Sandbox Code Playgroud)

canvas racket

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