小编Sur*_*Rao的帖子

如何在javascript中将字符串转换为布尔值?

我有一个从我的代码隐藏类返回到aspx页面的公共属性:

window.MyWIndow.IsFull = '<%=this.IsFull%>';
Run Code Online (Sandbox Code Playgroud)

在代码隐藏中,它是这样定义的:

public bool IsFull
{
    get;
    set;
}
Run Code Online (Sandbox Code Playgroud)

现在,当我在我的 javascript 文件中使用它时,我有以下代码:

var isShow = myself.IsFull;
Run Code Online (Sandbox Code Playgroud)

这种方式isShow'True''False'

我需要将其转换页面上的水平,所以isShowboolean不是string

所以我可以写if else逻辑

我该怎么做?

javascript code-behind type-conversion

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

Ionic AlertController和HTML代码

嗨想要这样的东西,并将css分配给每个div和地址块.可能吗???

let alert = this.alertCtrl.create({
            title: 'Contact Us',
            subTitle: `
                <div class="address-block pp-notes-row">

                    <address></address>
                </div>
            `,
            buttons: ['OK'],
            cssClass: `
                .alert-wrapper {
                    width: 100%
                }

                .address-block {
                    text-align: left;
                }
            `
        });
        alert.present();
Run Code Online (Sandbox Code Playgroud)

ionic-framework ionic2

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

在 Angular 2 中使用订阅获取 http 响应后获取 [object Object]

产品服务.ts

   getProduct(id: number): Observable<IProduct> {

    return this._http.get(this._productUrl + '/GetById/' + 
           id).map((response: Response) => <IProduct>response.json())           
        .catch(this.errorHandler);     
}
Run Code Online (Sandbox Code Playgroud)

产品详细信息组件.ts

   getProduct(id: number) {
    this._productService.getProduct(id).subscribe(
        res => {               
            console.log('before component ' + res);     
            this.product = res;
            console.log('after component ' + res);                
        },
        error => this.errorMessage = <any>error),
        console.log('execution complete'); 
}
Run Code Online (Sandbox Code Playgroud)

当在订阅中接收结果时,它会在
执行完成时出现,在组件 [object Object] 之前,在组件 [object Object] 之后

angularjs-directive angular-services angular2-routing angular

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

TypeError:无法设置未定义的属性'posts'-Vuejs

我使用VueJs和Laravel创建SPA。我通过api laravel和axio响应获得了所有帖子的主页数据对象。但是我无法更新到职位属性。

  • chrome调试工具错误:

TypeError:无法设置未定义的属性'posts'-Vuejs

我在Wellcome.vue中的代码

import { mapGetters } from 'vuex'
import axios from 'axios'
export default {
  name: 'welcome',

  layout: 'default',

  metaInfo: { titleTemplate: 'Welcome | %s' },

  computed: mapGetters({
    authenticated: 'authCheck'
  }),

  data: () => ({
    title: 'Demo Blog',
  }),
  props: {
      posts: {
        type: Object
      }
  },
  created () {
    axios.get('/api/posts')
    .then(function (response) {
      this.posts = response.data;
    })
    .catch(function (error) {
      console.log(error);
    });
  },
}
Run Code Online (Sandbox Code Playgroud)

laravel-5 axios vuejs2

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

在 TypeScript 泛型方法中将变量转换为 T?

我有以下typescript课程,从中获取模型localStorage

export class LocalStorageHelper {
    public static GetItemValue<T>(key: string): T {
        let value: string = localStorage.getItem(key);
        // if(typeof T == 'string') return value;
        // return (Convert JSON.parse(value) To T)
    }
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能在 TypeScript 中做类似注释行的事情?

type-conversion typescript

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

将对象添加到列表,更改所有其他列表对象

我正在尝试将动物添加到我的动物列表中,但最后添加的动物的值将是列表中的所有动物.

List<Animal> animals = new List<Animal>();
public bool AddAnimal(Animal animal)
        {
            animals.Add(animal); 
            return true;
        } 

Animal animal = new Animal();
private void btnAddAnimal_Click(object sender, RoutedEventArgs e)
        {
            animal.AnimalSize = Size.large;
            animal.Carnivore = true;
            AddAnimal(animal);
        }
Run Code Online (Sandbox Code Playgroud)

这是列表:大小食肉动物 - 大真

private void btnAddAnimal_Click(object sender, RoutedEventArgs e)
        {
            animal.AnimalSize = Size.large;
            animal.Carnivore = false;
            AddAnimal(animal);
        }
Run Code Online (Sandbox Code Playgroud)

这是我添加草食动物后我的动物列表中发生的事情:

  • 大小食肉动物
    • 大错
    • 大错

c# list

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

Ionic 3:使用蓝牙打印机打印图像

我目前正在努力使用我们的 Ionic3 应用程序。我似乎无法找到如何使用 BT 打印机和蓝牙串行插件打印图像。打印文本就好了。

我们正在使用此文档(由我的前同事找到)驱动程序命令文档测试 RPP02N-BU 打印机 ,但我无法获得

选择位图模式

上班。

我们首先将上传的图像调整为不超过 300 像素,然后将其转换为黑白。打印时,我们迭代图像并创建二进制字符串,然后将其转换为字节。这些字节跟在 SELECT BIT IMAGE MODE 命令之后。

我们的代码(在 TypeScript 中)如下:

/**
 * Image to printer command
 * @param image 
 */
public static getImagePrintData(image: HTMLImageElement): Buffer {
    // Initialize list of commands
    let command: number[] = [ 0x1b, 0x2a, 33, 255, 3 ];

    // Get image bytes
    let bytes = this.getImageBytes(image);

    // Add bytes to command
    bytes.forEach((byte) => command.push(byte));

    // Return command
    return new Buffer(command);
}

/** …
Run Code Online (Sandbox Code Playgroud)

printing image bluetooth typescript ionic3

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

不一致的用户名格式检查

如何检查用户名的格式是否正确?

例如这种格式:Test#1234

并且#后面不要检查超过4个数字。

我怎样才能做到这一点?

regex

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

ASP.NET core 3.1:向项目添加类库_ MissingMethodException:找不到方法:'Boolean Microsoft.EntityFrameworkCore.Migrations

我正在开发asp.net-core 3.1项目,我为我的项目添加了 3 个类库来分离访问数据、模型类和实用程序类,我解决了匹配文件夹等问题。但是当我运行我的项目时,我收到此错误:

MissingMethodException: Method not found: 'Boolean Microsoft.EntityFrameworkCore.Migrations.IMigrationsModelDiffer.HasDifferences(Microsoft.EntityFrameworkCore.Metadata.IModel, Microsoft.EntityFrameworkCore.Metadata.IModel)'.


   Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext 
   httpContext)
   System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<TStateMachine>(ref TStateMachine 
   stateMachine)
   System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<TStateMachine>(ref TStateMachine 
   stateMachine)
   Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext 
   httpContext)
   Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)  
Run Code Online (Sandbox Code Playgroud)

asp.net-core

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

无法加载 Powershell,因为该系统上禁用了运行脚本

我的问题与纱线有关。在我开始创建项目之前,我使用 npm 安装了。很长一段时间后,当我想开始使用纱线运行时,它显示以下错误:

yarn : File C:\Users\pc\AppData\Roaming\npm\yarn.ps1 cannot be loaded because running scripts is disabled on this system.
Run Code Online (Sandbox Code Playgroud)

(在 Windows 机器、Powershell 中)

窗户:10

我尝试使用 git bash 终端,它成功了!
但不在我的 powershell 终端中

windows powershell yarnpkg

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