小编Jef*_*tat的帖子

在webpack中动态添加全局常量

我正在尝试为我的项目添加一个全局常量.为此,我使用webpack.DefinePlugin.如果我在module.exports中添加一个,这是有效的.但是我没有条件地这样做.在下面的配置中,我可以__VERSION__在声明之后使用模块中的常量:declare var __VERSION__: string;.如果我尝试使用__VERSION2____VERSION3__在控制台中出现错误ReferenceError: __VERSION3__ is not defined.如果我的理解是正确的,那么应该更换.这是否意味着条件部分未执行或未正确执行?我该怎么调试呢?或者甚至更好,我该如何解决这个问题?

注意:目的是根据开发或生产构建切换URL.

目前的项目可以在github上找到

webpack.config.js:

// Based on https://github.com/microsoft/typescript-vue-starter#adding-webpack

var path = require('path')
var webpack = require('webpack')

module.exports = {
    mode: 'development',
  entry: './src/ts/main.ts',
  output: {
    path: path.resolve(__dirname, './dist'),
    publicPath: '/dist/',
    filename: 'build.js'
  },
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: {
            // Since sass-loader (weirdly) has SCSS as its default parse mode, we map …
Run Code Online (Sandbox Code Playgroud)

javascript typescript webpack vue.js

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

如何在 MVVM 中使用 ApplicationCommands

我想使用 ApplicationCommands.Cut、复制、粘贴、保存……它们看起来很有趣,因为命令路由、键绑定以及某些控件使用它们的事实。我了解如何绑定到 VM 上的中继/委托命令,但我似乎无法理解应用程序命令。我找到了几个旧答案,但没有其他信息,我有点不愿意遵循这些路线。

这似乎很常见,但信息似乎非常有限。这通常是如何实现的?(无论是否使用 PRISM、MVVM Light,...)

旧答案:

如何将 ApplicationCommands 绑定到 ViewModel但这对我来说使用行为解决这个问题似乎很奇怪

WPF - 在 ViewModel 中处理 ApplicationCommand但我认为这不是已接受答案中的 MVVM。

在旧文章中使用附加属性:CommandBindings with MVVM引用另一篇文章。

c# wpf mvvm

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

DelegateCommand 抛出“指定的强制转换无效”

我想使用带有 bool 作为参数的 PRISM 委托命令。这是相关代码:

public class ChartViewModel : BindableBase
{
    public DelegateCommand<bool?> ChangeZoomPanCommand { get; private set; }

    private bool isInRealtimeMode;
    public bool IsInRealtimeMode
    {
        get { return isInRealtimeMode; }
        set
        {
            SetProperty(ref isInRealtimeMode, value);
            ChangeZoomPanCommand.RaiseCanExecuteChanged();
        }
    }

    private bool dragToZoom;
    public bool DragToZoom
    {
        get { return dragToZoom; }
        set { SetProperty(ref dragToZoom, value); }
    }


    public ChartViewModel()
    {
        ChangeZoomPanCommand = new DelegateCommand<bool?>(ExecuteChangeZoomPan, CanExecuteChangeZoomPan);
        IsInRealtimeMode = true;
        DragToZoom = true;
    }

    private bool CanExecuteChangeZoomPan(bool? arg)
    {
        return !IsInRealtimeMode; …
Run Code Online (Sandbox Code Playgroud)

wpf prism delegatecommand

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

从dll返回多个字符串

我们正在讨论什么是从一个dll函数返回多个字符串的好方法.目前我们有8个字符串,但会有更多.为简单起见,我现在认为所有字符串都有相同的长度.

extern "C" int DLLNAME_ _stdcall GetResult(TestResults* testResults);
Run Code Online (Sandbox Code Playgroud)

哪里

struct TestResults
{
    int stringLengths;
    char* string1;
    char* string2;
    char* string3;
    char* string4;
    ...
};
Run Code Online (Sandbox Code Playgroud)

或第二种选择:在哪里

struct TestResults
{
    int stringLengths;
    char string1[64];
    char string2[64];
    char string3[64];
    char string4[64];
    ...
};
Run Code Online (Sandbox Code Playgroud)

第三个选项:extern"C"int DLLNAME_ _stdcall GetResult(int stringLengths,char*string1,char*string2,char*string3,...);

dll将通过串行线进行通信,并检索将填充到字符串中的信息.需要分配内存的地方可供讨论,可以作为答案的一部分.

背景是我们有一个VB6应用程序团队更喜欢第二种方法,而C++/C#团队更喜欢第一种方法.最后一个方法看起来适合两个团队,但看起来有点奇怪我有这么多参数.

也许还有更多的选择.Windows下的常见做法是什么?Windows API或参数中的任何示例都可以选择其中一个?

编辑:字符串具有名字,姓氏,电子邮件的含义.我们目前有八个,但将来我们可能会添加一对例如地址.数组不是正确的选择,但原始上下文中并不清楚.

c++ windows string dll

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

标签 统计

wpf ×2

c# ×1

c++ ×1

delegatecommand ×1

dll ×1

javascript ×1

mvvm ×1

prism ×1

string ×1

typescript ×1

vue.js ×1

webpack ×1

windows ×1