Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

blazor server side - Custom Razor component a NuGet library behaves differently?

I created 3 components which have the exact same implementation with only 1 difference:

  • The 1st component (MyTest) is implemented in the same project as its parent component
  • The 2nd one (Component1) is from a different (but same solution)
  • The 3rd (CSInput) is imported from a NuGet package. Below are the invokation of all 3 in the same parent.

The razor component implementation is as followed:

<input disabled="@Disabled">

@code {
 [Parameter]
 public bool Disabled { get; set; }
}

The snippet of the parent implementation:

// The Disabled property is coded as boolean
<MyTest Disabled="@DisableMyTest"/>
<RazorClassLibrary1.Component1 Disabled="@DisableMyTest" />
<CSInput Disabled="@DisableMyTest"/>

@code{
  private bool DisableMyTest = false;
}

For an unknown reason, the compiler issued a CS1503 (cannot convert from 'bool' to 'string') on the Disabled property from CSInput. Any idea why? Many Thanks!

question from:https://stackoverflow.com/questions/65838164/custom-razor-component-a-nuget-library-behaves-differently

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

figured it out. The weird behavior is caused by me not incrementing the version of the nuget. Whenever you install a Nuget, VS keeps a copy of it in the .nugetpackages directory. If you don't clean up that directory, VS will keep use what it has. Now, where can I get wig....


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...