小编San*_*nti的帖子

React-Native ListView renderRow发出传递道具.正确的方式或错误的方式

在React-Native中使用ListView,我看到不一样,将props移动到列表项,

  1. 仅使用引用将函数作为props传递,并调用子组件中的参数,或

  2. 将函数作为带有参数定义的props传递,并调用子函数中没有参数的函数

没有一个解决方案有效.

调用的函数是Redux的Actions创建者,并被调度.这是Redux还是React-Native(也许是ReactJS)的问题

这是一个片段,市场为//错误的代码行无效后跟好的代码行

class App extends Component {

  // On props 
  // data: an Array
  // doThis: an action creator of Redux
  // doThat: idem

  constructor(){
    super();
    this.ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
  }

  render () {
    const dataSource = this.ds.cloneWithRows(this.props.data);

    return (
      <View>
        <ListView style={{flex:1}}
            dataSource={dataSource}
            renderRow={(rowData, sectionID, rowID) =>
              <Item  rowData={rowData}
              //ERROR
              //onPress={this.props.doThis}
              //onLongPress={this..props.doThat}
              //RIGHT NO ERROR TOO
              onPress={() => this.props.doThis(rowData)}
              onLongPress={() => this.props.doThat(rowData)}
              />
            }
          />
      </View>
    )
  }
} …
Run Code Online (Sandbox Code Playgroud)

android ios reactjs react-native redux

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

F#:[&lt;StructuredFormatDisplay&gt;] 与覆盖 __.ToString()。¿有什么问题吗?

dotnet 2.2.203 上下文:在Ubuntu 18.04 桌面计算机上的容器化环境中运行 F#

问题:StructuredFormatDisplay组合记录中的 不起作用。是不是错了?这是代码

[<StructuredFormatDisplay("{SizeGb}GB")>]
type Disk = 
    { SizeGb : int }
    override __.ToString() = sprintf "<%dGB>" __.SizeGb

[<StructuredFormatDisplay("Computer #{Id}: {Manufacturer}/{DiskCount}:{Disks}")>]
type Computer =
    { Id: int
      mutable Manufacturer: string
      mutable Disks: Disk list }
      override __.ToString() = sprintf "#%d<%s>%O" __.Id __.Manufacturer __.Disks


[<EntryPoint>]
let main argv =

    let myPc =
        { Id = 0
          Manufacturer = "Computers Inc."
          Disks =
            [ { SizeGb = 100 }
              { SizeGb = 250 }
              { …
Run Code Online (Sandbox Code Playgroud)

f# attributes record tostring

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

CKAN ERROR预览CSV,但可以下载

我在我的本地测试机器中有以下错误,只是instaled.Ckan,datapusher,数据存储都在同一台机器上.

访问csv资源我有以下消息; "此资源视图目前不可用.点击此处获取更多信息.

无法加载视图:DataProxy返回错误(数据转换失败.错误:连接到服务器时出错:无法连接到URL上的服务器:http://192.168.146.131/dataset/f2139e6a-7e22-41b1-97c2 -51101dcfee2f/resource/015a5fc1-efac-49c8-9aff-82b04b0bdc93/download/MICSV.csv)"

用于测试burt的简单CSV无法看到URL正常,我可以通过在导航栏中复制/粘贴来访问resorce.在conf中可能有些事情.我忘记了一个插件?

我的conf文件中修改过的行是:

sqlalchemy.url = postgresql://ckan_default:pass@localhost/ckan_default
ckan.datastore.write_url =     postgresql://ckan_default:pass@localhost/datastore_de
Run Code Online (Sandbox Code Playgroud)

fault ckan.datastore.read_url = postgresql:// datastore_default:pass @ localhost/datastor e_default

ckan.site_url = http://127.0.0.1
solr_url = http://127.0.0.1:8983/solr
ckan.storage_path = /var/lib/ckan/default
ckan.datapusher.url = http://127.0.0.1:8800
ckan.plugins = stats text_view image_view recline_view datastore datapus       her resource_proxy recline_preview
Run Code Online (Sandbox Code Playgroud)

ubuntu-12.04 ckan

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

成员与类的F#记录

在F#中,您可以使用成员函数定义记录,也可以创建类。

type Album = {
    Id: int
    Name: string
    DateReleased: DateTime
    Genre: Genre }
with
    member this.PrintMessage() =
        printf "Hello from %s\n" this.Name
Run Code Online (Sandbox Code Playgroud)

这么用

let first = 
        { Id = 1; 
          Name = "Hello World!"
          Genre = KPop;
          DateReleased = DateTime(1991, 8, 12) }
first.PrintMessage()
Run Code Online (Sandbox Code Playgroud)

与类可能是这样的。

type Album(
     Id: int, 
     Name: string, 
     DateReleased: DateTime, 
     Genre: Genre ) as me =
     do
         me.PrintMessage()
     member this.PrintMessage() =
         printf "Hello %s" Name
Run Code Online (Sandbox Code Playgroud)

什么时候方便使用另一个?只能对记录进行域建模吗?

是否可以通过某些隐藏的FSharp Casting将类转换为记录,反之亦然?

f#

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

标签 统计

f# ×2

android ×1

attributes ×1

ckan ×1

ios ×1

react-native ×1

reactjs ×1

record ×1

redux ×1

tostring ×1

ubuntu-12.04 ×1